[issue31031] Unify duplicate bits_in_digit and bit_length
STINNER Victor
report at bugs.python.org
Thu Jan 16 09:13:46 EST 2020
STINNER Victor <vstinner at python.org> added the comment:
"On BSD, there's a library function called fls() that we could use, and GCC provides __builtin_clz()."
See also rejected bpo-29782 and GH-594.
If someone wants to experiment that, I suggest to add Include/internal/pycore_pymath.h, move _Py_bit_length() there and convert it to a static inline function.
Since the code is now unified, it makes a little bit more sense to add specialized code, *if* the code is not too complex.
I'm still not sure that GH-594 is worth it, since it was not possible to see the speedup on a microbenchmark :-(
----------
_______________________________________
Python tracker <report at bugs.python.org>
<https://bugs.python.org/issue31031>
_______________________________________
More information about the Python-bugs-list
mailing list