-
-
Notifications
You must be signed in to change notification settings - Fork 31.4k
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
bpo-47012: speed up iteration of bytes and bytearray #31867
Conversation
I agree with @animalize that it would be safest to include a preprocessor directive, whether that's with separate I'm not sure why anyone would compile with fewer than 256 cached small ints. Here, @vstinner added the code // _PyLong_GetZero() and _PyLong_GetOne() must always be available
#if _PY_NSMALLPOSINTS < 2
# error "_PY_NSMALLPOSINTS must be greater than 1"
#endif @vstinner, would there be any downside to requiring all of |
I don't think that anyone ever tuned _PY_NSMALLPOSINTS. The value should be hardcoded. But just for sanity, you can add a static_assert() in code which makes assumptions about its value, just in case if someone changes _PY_NSMALLPOSINTS in the future. For example, I added assertions to ensure that 0 and 1 singletons always exist. |
@sweeneyde I have added the compilation guard, but FYI if _PY_NSMALLPOSINTS is changed then it would break deepfreeze and module freezing infra so it is not configurable not to mention that it is declared in internal header. |
Benchmark:
Results:
https://bugs.python.org/issue47012