Skip to content

PERF: Increase threashold for using binary search in IndexEngine #54746

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 4 commits into from
Aug 26, 2023
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion doc/source/whatsnew/v2.2.0.rst
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ Deprecations

Performance improvements
~~~~~~~~~~~~~~~~~~~~~~~~
-
- Increase the threshold to use binary search instead of a linear search in IndexEngine :issue:`54550`
Copy link
Member

@mroeschke mroeschke Aug 25, 2023

Choose a reason for hiding this comment

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

Suggested change
- Increase the threshold to use binary search instead of a linear search in IndexEngine :issue:`54550`
- Performance improvement when indexing with more than 4 keys (:issue:`54550`)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Nice, thanks a lot for the review.
done!

-

.. ---------------------------------------------------------------------------
Expand Down
2 changes: 1 addition & 1 deletion pandas/_libs/index.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -375,7 +375,7 @@ cdef class IndexEngine:
# map each starget to its position in the index
if (
stargets and
len(stargets) < 5 and
len(stargets) < (n / (2 * n.bit_length())) and
Copy link
Contributor Author

Choose a reason for hiding this comment

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

bit_lenght is just a fast way of computing the ceiling of log2.

not na_in_stargets and
self.is_monotonic_increasing
):
Expand Down