ENH: Add RangeIndex union fast-path in union_indexes - #66293
Open
rajat315315 wants to merge 7 commits into
Open
Conversation
Member
|
can you double-check this on |
…ng RangeIndex set operation test coverage
Contributor
Author
|
Apologies, missed one case! The initial implementation sorted the list of non-empty ranges by their start values (or start values descending if step < 0) but assumed the last sorted range had the largest stop value. If one range was entirely contained inside another, or if there were duplicate start values with different stop values, the final range bound returned was incorrect. I have fixed it and also added new test-cases to cover these as well. |
Contributor
Author
|
Benchmark Results (10,000 Runs)
|
Member
|
please have your favorite AI fuzz this for cases you missed |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Resolves / Closes: PERF: union_indexes is slow for homogeneous RangeIndexes during DataFrame concatenation #66292
Summary of changes:
union_indexeswhen all input indexes areRangeIndexinstances.RangeIndexes to avoid redundantO(N)iterative set operations (e.g. when unioning identical column indices duringpd.concat).RangeIndexes with matching steps into a singleRangeIndexwithout callingunioniteratively.Noneif they do not match.pandas/tests/indexes/ranges/test_setops.pyto cover identical, contiguous, overlapping, non-contiguous, empty, and name-reconciliation cases.Performance Impact:
Benchmark results for concatenating 2,000 DataFrames (average of 5 runs):
closes #xxxx (Replace xxxx with the GitHub issue number)
Tests added and passed if fixing a bug or adding a new feature
All code checks passed.
Added type annotations to new arguments/methods/functions.
Added an entry in the latest
doc/source/whatsnew/vX.X.X.rstfile if fixing a bug or adding a new feature.I have reviewed and followed all the contribution guidelines
If I used AI to develop this pull request, I prompted it to follow
AGENTS.md.