GH-129149: Add fast paths to four more PyLong_From* functions#131211
GH-129149: Add fast paths to four more PyLong_From* functions#131211picnixz merged 4 commits intopython:mainfrom
PyLong_From* functions#131211Conversation
PyLong_From* functions
PyLong_FromInt32(), PyLong_FromInt64(), PyLong_FromUInt32() and PyLong_FromUInt64()PyLong_From* functions
picnixz
left a comment
There was a problem hiding this comment.
Are the tests also updated accordingly? (namely do they correctly test all paths?)
|
Pretty much the same as cpython/Modules/_testlimitedcapi/long.c Lines 772 to 781 in 1a8e574 and then using check_long_asint, where I've already added more values to cover more cases (especially negative small and medium-size integers): #129301 (comment)
|
|
Maybe add even more values? Definitely no performance bottleneck and might gain test coverage. E.g. one more positive and negative small integer? |
If we're already covering the small, medium and large integers, both in negative and positive ranges, it's fine. |
|
@vstinner are you fine with this? (sorry for the ping, though) |
|
Thank you! |
Use the macro
PYLONG_FROM_INTto implementPyLong_FromInt32()andPyLong_FromInt64(), and the macroPYLONG_FROM_UINTto implementPyLong_FromUInt32()andPyLong_FromUInt64(), because they have a fast path for small and medium-size integers.before:
after:
Benchmark done like in #129301 (comment).