Skip to content

BUG: RangeIndex.nbytes/memory_usage raised TypeError on PyPy (GH-46176)#65601

Open
jbrockmendel wants to merge 2 commits into
pandas-dev:mainfrom
jbrockmendel:bug-46176
Open

BUG: RangeIndex.nbytes/memory_usage raised TypeError on PyPy (GH-46176)#65601
jbrockmendel wants to merge 2 commits into
pandas-dev:mainfrom
jbrockmendel:bug-46176

Conversation

@jbrockmendel
Copy link
Copy Markdown
Member

Summary

`sys.getsizeof` always raises `TypeError` on PyPy unless a default is provided, so `RangeIndex.nbytes` (and the `memory_usage` that delegates to it) blows up on PyPy. Pass the same fallback default already used in `MultiIndex._nbytes` (`24`).

Test plan

  • Added `test_nbytes_pypy_compat` that monkeypatches `getsizeof` to mimic PyPy semantics (TypeError unless `default` is given) so the regression is covered on CPython CI.
  • Existing `test_nbytes` still passes — CPython values are unchanged since the fallback only fires when `getsizeof` would otherwise raise.

🤖 Generated with Claude Code

jbrockmendel and others added 2 commits May 11, 2026 13:04
sys.getsizeof always raises TypeError on PyPy unless a default is
provided. Pass the same fallback default already used in
MultiIndex._nbytes so RangeIndex.nbytes (and memory_usage) keep working
on PyPy.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

getsizeof usage for memory utilization estimation is incompatible with PyPy

1 participant