-
-
Notifications
You must be signed in to change notification settings - Fork 18.4k
PERF: avoid unnecessary reordering in MultiIndex._reorder_indexer #48384
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
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.
Thanks @lukemanley, looks good to me.
Can you merge master into your branch? I think CI problems should be fixed now.
# check if sorting is necessary | ||
need_sort = False | ||
for i, k in enumerate(seq): | ||
if com.is_null_slice(k) or com.is_bool_indexer(k) or is_scalar(k): |
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.
Do we have unit tests for all these new branches that short circuit?
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.
I'm pretty there are tests that hit these in one way or another. Regardless, I just added test_get_locs_reordering that explicitly tests the ordering effects of: null slices, bool indexers, scalars, and lists of length 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.
Great thanks!
Thanks @lukemanley |
…ndas-dev#48384) * Avoid unnecessary reordering in MultiIndex._reorder_indexer * whatsnew * mypy * cleanup * add multiindex.get_locs reordering tests * fix test Co-authored-by: Matthew Roeschke <[email protected]>
doc/source/whatsnew/v1.6.0.rst
file if fixing a bug or adding a new feature.MultiIndex._reorder_indexer
contains logic to determine if indexer reordering is required. This PR expands the logic a bit to identify additional cases where reordering is not necessary.ASVs: