Skip to content

PERF: Improve performance for array equal fast #50850

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 3 commits into from
Jan 20, 2023

Conversation

phofl
Copy link
Member

@phofl phofl commented Jan 18, 2023

  • 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.

gives us a 50% boost if everything is equal and reduces it to nanoseconds if the first non-equal element is within the first couple elements compared to 500 microseconds

def array_equal_fast(
ndarray[int6432_t, ndim=1] left, ndarray[int6432_t, ndim=1] right,
) -> bool:
def indexer_equal_fast(ndarray[int6432_t, ndim=1] left, int n) -> bool:
Copy link
Member

Choose a reason for hiding this comment

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

While renaming this function, maybe is_range_indexer might be more appropriate? Or at least clarifying that this only compares if the indexer is equal to range(n)

Copy link
Member Author

Choose a reason for hiding this comment

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

Yeah thought about this myself and agree.

Copy link
Member Author

Choose a reason for hiding this comment

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

Changed

@mroeschke mroeschke added the Performance Memory or execution speed performance label Jan 19, 2023
Copy link
Member

@jorisvandenbossche jorisvandenbossche left a comment

Choose a reason for hiding this comment

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

Yes, looks good! (that's what I had in mind as well)

@phofl phofl merged commit 86ae81c into pandas-dev:main Jan 20, 2023
@phofl phofl deleted the perf_array_equal_fast branch January 20, 2023 17:03
pooja-subramaniam pushed a commit to pooja-subramaniam/pandas that referenced this pull request Jan 25, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Performance Memory or execution speed performance
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants