Skip to content
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

searchsorted ranges: simplify code, fix bug with Unsigned needle #40364

Merged
merged 2 commits into from
Apr 8, 2021

Conversation

vtjnash
Copy link
Member

@vtjnash vtjnash commented Apr 6, 2021

There seemed to be some unnecessary arithmetic and cases, costing performance (and correctness missed in #34224 fix). Rework some of the cases to avoid unnecessary computation (and still pass tests). Notably, this avoids computing length unnecessarily, which often requires a division, and is therefore often expensive. Along with #40358, this solves the performance gap noticed in #38527 with repeated lookups.

As a PSA: I made these test arrays Any[ ... ], since otherwise you risk having a promotion rule rewrite all of the test types into a single common type, defeating the purpose of the loop. Another solution would have been to use () instead of Any[].

This avoids computing `length` unnecessarily, which often requires a
division, and is therefore often expensive.
@vtjnash vtjnash added bugfix This change fixes an existing bug backport 1.6 Change should be backported to release-1.6 labels Apr 6, 2021
@vtjnash vtjnash requested a review from rfourquet April 6, 2021 01:25
@KristofferC KristofferC mentioned this pull request Apr 6, 2021
33 tasks
@vtjnash vtjnash merged commit d3b012b into master Apr 8, 2021
@vtjnash vtjnash deleted the jn/searchsorted-unsigned-bug branch April 8, 2021 19:43
@KristofferC KristofferC added backport 1.6 Change should be backported to release-1.6 and removed backport 1.6 Change should be backported to release-1.6 labels Apr 14, 2021
@KristofferC KristofferC removed the backport 1.6 Change should be backported to release-1.6 label May 4, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bugfix This change fixes an existing bug
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants