bpo-47012: speed up iteration of bytes and bytearray#31867
bpo-47012: speed up iteration of bytes and bytearray#31867sweeneyde merged 7 commits intopython:mainfrom
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