-
-
Notifications
You must be signed in to change notification settings - Fork 31.2k
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-130599: precompute conversion constants for long()
#130714
Conversation
This avoids a data race in free-threaded builds due to mutating the statically arrays at runtime. Instead, compute and initialize the constants at runtime initialization.
You need to add the new static globals to ignored.tsv. |
Given that Sam expressed a preference to not compute at startup time, I investigated how that looks. It turns out that 15 and 30 are the only allowed values for I updated |
Since the table is now statically defined, it can be marked as const as it is read only. |
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 measured the difference for ./python -c "pass"
between this and the earlier commit that computed the values at runtime initialization. It's very small, about 0.1%, so I if you prefer that approach, that seems fine to me too.
Use "const" and fix the swapped types of convmultmax_base and convwidth_base.
This makes the pre-computed tables match exactly what was previously computed at runtime, if all base conversions were used. This makes them slightly smaller too.
This avoids a data race in free-threaded builds due to mutating the static conversion arrays at runtime. Instead, compute and initialize the constants at runtime initialization. We only need to do this once (not once per interpreter) and so I added
_PyLong_InitRuntime()
.