Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

PERF: Series(dict) returns RangeIndex when possible #58118

Merged
merged 4 commits into from
Apr 3, 2024

Conversation

mroeschke
Copy link
Member

Discovered in #57441

@mroeschke mroeschke added Index Related to the Index class or subclasses Series Series data structure labels Apr 2, 2024
@mroeschke mroeschke added this to the 3.0 milestone Apr 3, 2024
np_sequence = np.asarray(sequence, dtype=np.int64)
try:
np_sequence = np.asarray(sequence, dtype=np.int64)
except OverflowError:
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why is the OverflowError required in this case? Have we added that elsewhere to support the RangeIndex return?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This line will fail if the sequence contains an int over the max int64 value e.g. test_loc_uint64.

This is the only pathway that can convert an arbitrary sequence to a RangeIndex return

@WillAyd WillAyd merged commit 1ee5832 into pandas-dev:main Apr 3, 2024
46 checks passed
@WillAyd
Copy link
Member

WillAyd commented Apr 3, 2024

Thanks @mroeschke

This pull request was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Index Related to the Index class or subclasses Series Series data structure
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants