Skip to content

ENH: Implement fastpath for masked indexes in join #50310

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

Merged
merged 6 commits into from
Dec 19, 2022

Conversation

phofl
Copy link
Member

@phofl phofl commented Dec 17, 2022

  • 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.rst file if fixing a bug or adding a new feature.

As of right now, masked indexes go through object even though we only use the join functions when we are monotonic, e.g. no NA present. We can simply use the numpy array to perform the join.

       before           after         ratio
     [026a83e0]       [d804bced]
-     5.82±0.02ms      1.38±0.02ms     0.24  index_object.SetOperations.time_operation('monotonic', 'ea_int', 'intersection')
-     4.08±0.03ms         452±10μs     0.11  index_object.SetOperations.time_operation('monotonic', 'ea_int', 'union')

This is related to #49420, will make it a bit easier to review since it solves the join changes

@phofl phofl added Performance Memory or execution speed performance NA - MaskedArrays Related to pd.NA and nullable extension arrays Index Related to the Index class or subclasses labels Dec 17, 2022
@phofl phofl changed the title ENH: Implement fastpath for ea indexes in join ENH: Implement fastpath for masked indexes in join Dec 17, 2022
functions.
"""
if isinstance(self._values, BaseMaskedArray):
# This is only used if our array is monotonic, so no NAs present
Copy link
Member

@mroeschke mroeschke Dec 19, 2022

Choose a reason for hiding this comment

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

Where is the monoticity of self._values._data checked?

Copy link
Member Author

Choose a reason for hiding this comment

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

Using those functions is guarded by those checks. The actual join implementations here only work with monotonic data. As soon as we reach _inner_indexer and others we have to be monotonic

Copy link
Member

Choose a reason for hiding this comment

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

Ah okay cool

@mroeschke mroeschke added this to the 2.0 milestone Dec 19, 2022
@mroeschke mroeschke merged commit 6cbd87b into pandas-dev:main Dec 19, 2022
@mroeschke
Copy link
Member

Thanks @phofl

@phofl phofl deleted the merge_nullable branch December 19, 2022 22:17
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 NA - MaskedArrays Related to pd.NA and nullable extension arrays Performance Memory or execution speed performance
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants