fix: restore performance in Coordinates.to_index()#11308
Closed
armorbreak001 wants to merge 1 commit intopydata:mainfrom
Closed
fix: restore performance in Coordinates.to_index()#11308armorbreak001 wants to merge 1 commit intopydata:mainfrom
armorbreak001 wants to merge 1 commit intopydata:mainfrom
Conversation
…ssary list conversions The mypy type fix in a13a255 converted code_list (ndarray) and level_list (Index) to Python lists before passing to pd.MultiIndex, causing a major performance regression in to_index() and downstream operations like to_dataframe(). Revert the conversions since pandas accepts ndarray codes and Index levels directly.
Contributor
|
duplicates #11306 |
Collaborator
|
thank you @armorbreak001 but I'm going to close as an earlier PR fixed this issue |
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.
Summary
Fixes #11305 — performance regression in
Coordinates.to_index()(and downstreamto_dataframe()).Details
Commit a13a255 (mypy type fix) converted
code_listfrom ndarray to Python lists via[list(c) for c in code_list]before passing topd.MultiIndex(). This introduced a major slowdown because:The fix passes
code_list(ndarray) directly topd.MultiIndex(codes=...), which pandas accepts natively. Thelevel_list += levelsline was already reverted in a later commit, so only thecodes=conversion needed fixing.Change: 1 line, net -1/+1.