Re:Python Standard Library changes in recent years
by saagarjha on Saturday May 21, 2022 @04:41AM
(#31456294)
Sadly it does not call into the hardware implementation: https://github.com/python/cpython/blob/f62ad4f2c4214fdc05cc4...
Re:Python Standard Library changes in recent years
by orlp on Saturday May 21, 2022 @04:53AM
(#31456352)
It does. Note that it calls popcount_digit on each digit of the integer (a 'digit' here is 32 bits), which calls _Py_popcount32, which does map to a hardware instruction if possible: https://github.com/python/cpython/blob/f62ad4f2c4214fdc05cc4...
I guess it's included as an easy way to access the fast hardware supported implementation, on architectures where it is available.