-
-
Notifications
You must be signed in to change notification settings - Fork 31.9k
gh-119714: Add PyLong_GetNumBits() function #119715
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
Conversation
self.assertEqual(numbits(0), 0) | ||
self.assertEqual(numbits(7), 3) | ||
self.assertEqual(numbits(-37), 6) | ||
self.assertEqual(numbits(684_643_661_981), 40) | ||
self.assertEqual(numbits(2**123-1), 123) |
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.
There are no tests for the two overflow cases.
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 added a test, but it requires 1145324612.3 GiB of memory to run :-) On 32-bit systems, the test pass and only requires 273 MiB.
Co-authored-by: Erlend E. Aasland <erlend.aasland@protonmail.com>
Co-authored-by: Erlend E. Aasland <erlend.aasland@protonmail.com>
PR rebased to fix merge conflicts with the main branch (with the new PyLong_GetSign() function). |
The C API Working Group rejected this API: |
📚 Documentation preview 📚: https://cpython-previews--119715.org.readthedocs.build/