-
-
Notifications
You must be signed in to change notification settings - Fork 18.4k
PERF: Add short circuiting to RangeIndex._shallow_copy #57534
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
Conversation
pandas/core/indexes/range.py
Outdated
diff = values[1] - values[0] | ||
if diff == 0: | ||
return False | ||
curr = values[1] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is still pretty slow I think, I think what you are looking for is is_range_indexer
that we built for CoW with a stepsize argument added
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah gotcha. I refactored to use is_range_indexer
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just to be clear, that will only work with stepsize 1 for now, I am open to support other step sizes as well if you like (follow up should be fine)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Right I "normalize" the values by the stepsize (values - values[0] / values[1] - values[0]
) so that is_range_indexer
can always be used here
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah sorry, yeah that makes sense
thx |
Still a 10% slowdown compared to before, could you check if we can close the gap further? |
xref #57445 (comment)
There needs to be More Work done to attempt to return a RangeIndex, but this should help minimize that Work