-
-
Notifications
You must be signed in to change notification settings - Fork 31.9k
Emscripten: use better _Py_Version
computation for worker module
#129757
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
Emscripten: use better _Py_Version
computation for worker module
#129757
Conversation
Most changes to Python require a NEWS entry. Add one using the blurb_it web app or the blurb command-line tool. If this change has little impact on Python users, wait for a maintainer to apply the |
This is my first PR to CPython, and I have signed the CLA. The |
_Py_Version
computation for worker module_Py_Version
computation for worker module
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.
Agreed - that is a lot more elegant! Thanks for the patch!
|
…ython#129757) Use integer bit shifting instead of conversion to strings to compute Python version.
Buildbot failure is unrelated to this change; it looms like a network connectivity issue on the host machine. |
…ython#129757) Use integer bit shifting instead of conversion to strings to compute Python version.
Related to gh-127113
This is a small PR that improves the _Py_Version check for the Python worker module file for the Emscripten builds, which was last modified in https://github.com/python/cpython/pull/127113/files#diff-31f61a127a59386957acba86e9acedf0a96bc6ebe1ac159a48e39b1a291111b5R73-R75. I reviewed the corresponding change downstream in pyodide/pyodide#5406 and suggested this change, and @hoodmane suggested that I should upstream the change here.
The idea is that we were converting a number to a hex string, then padding that string, splitting it up, and then bringing it back by parsing it to an integer – these operations are unnecessary. We can instead use an unsigned right shift and apply a bitmask to grab the relevant bytes. For the format
0xMMmmpp00
, this means that the major version is in bits 24–31, the minor version in bits 16–23, and the patch/micro version in bits 8–15. These bit operations should be more direct.