You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Currently PyLong_FromSize_t() uses PyLong_FromLong() for values < PyLong_BASE. It's suboptimal because PyLong_FromLong() needs to handle the sign. Removing PyLong_FromLong() call and handling small ints directly in PyLong_FromSize_t() makes it faster:
This change makes PyLong_FromSize_t() consistently faster than PyLong_FromSsize_t(). So it might make sense to replace PyLong_FromSsize_t() with PyLong_FromSize_t() in __length_hint__() implementations and other similar cases. For example:
New changeset c6734ee by Gregory P. Smith (Sergey Fedoseev) in branch 'master': bpo-37802: Slightly improve perfomance of PyLong_FromUnsigned*() (GH-15192) c6734ee
Activity
sir-sigurd commentedon Aug 9, 2019
Currently PyLong_FromSize_t() uses PyLong_FromLong() for values < PyLong_BASE. It's suboptimal because PyLong_FromLong() needs to handle the sign. Removing PyLong_FromLong() call and handling small ints directly in PyLong_FromSize_t() makes it faster:
This change makes PyLong_FromSize_t() consistently faster than PyLong_FromSsize_t(). So it might make sense to replace PyLong_FromSsize_t() with PyLong_FromSize_t() in __length_hint__() implementations and other similar cases. For example:
sir-sigurd commentedon Aug 25, 2019
Previous benchmarks results were obtained with non-LTO build.
Here are results for LTO build:
gpshead commentedon Sep 12, 2019
New changeset c6734ee by Gregory P. Smith (Sergey Fedoseev) in branch 'master':
bpo-37802: Slightly improve perfomance of PyLong_FromUnsigned*() (GH-15192)
c6734ee
vstinner commentedon Oct 1, 2019
New changeset 6314abc by Victor Stinner in branch 'master':
bpo-37802: Fix a compiler warning in longobject.c (GH-16517)
6314abc