-
-
Notifications
You must be signed in to change notification settings - Fork 31.8k
gh-90213: Speed up right shifts of negative integers #30277
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
gh-90213: Speed up right shifts of negative integers #30277
Conversation
One example timing: evaluating -7**100 >> 123 is approximately twice as fast on this branch as on main:
|
Smaller and larger examples also benefit on my machine:
|
I've reworked to remove the duplication between the positive and negative branches, and to move the shift==0 check earlier. |
Misc/NEWS.d/next/Core and Builtins/2021-12-24-20-21-45.bpo-46055.R0QMVQ.rst
Outdated
Show resolved
Hide resolved
🤖 New build scheduled with the buildbot fleet by @mdickinson for commit b3a1a8f 🤖 If you want to schedule another build, you need to add the ":hammer: test-with-buildbots" label again. |
🤖 New build scheduled with the buildbot fleet by @mdickinson for commit fd4ce81 🤖 If you want to schedule another build, you need to add the ":hammer: test-with-buildbots" label again. |
This PR is stale because it has been open for 30 days with no activity. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not sure that I understand 100%, but I think it is correct and it does pass the tests.
A few of the variables could have their scope narrowed.
@markshannon Thanks for the review! I've addressed your comments, and I think this should be ready for re-review. |
🤖 New build scheduled with the buildbot fleet by @mdickinson for commit c5e3f81 🤖 If you want to schedule another build, you need to add the ":hammer: test-with-buildbots" label again. |
AFAICT this looks good, and all the buildbots are happy. |
Taking some ideas from the work of @xuxinhang in #30044, this PR makes right shift of negative integers more efficient, by avoiding the need for temporary intermediate results.
Closes #90213
https://bugs.python.org/issue46055