bpo-31031: Unify duplicate bits_in_digit and bit_length by niklasf · Pull Request #2866 · python/cpython

auvipy

vstinner

mdickinson

vstinner

vstinner

@niklasf

vstinner

shihai1991 pushed a commit to shihai1991/cpython that referenced this pull request

Jan 31, 2020
Add _Py_bit_length() to unify duplicate bits_in_digit() and bit_length().

niklasf added a commit to niklasf/cpython that referenced this pull request

Jun 8, 2020
In pythonGH-2866, _Py_Bit_Length() was added to pymath.h for lack of a better
location. pythonGH-20518 added a more appropriate header file for bit utilities. It
also shows how to properly use intrinsics. This allows reconsidering bpo-29782.

* Move the function to the new header.
* Changed return type to match __builtin_clzl and reviewed usage.
* Use intrinsics where available.
* Pick a (mostly theoretical) fallback implementation suitable for
  inlining.

vstinner pushed a commit that referenced this pull request

Jun 15, 2020
In GH-2866, _Py_Bit_Length() was added to pymath.h for lack of a better
location. GH-20518 added a more appropriate header file for bit utilities. It
also shows how to properly use intrinsics. This allows reconsidering bpo-29782.

* Move the function to the new header.
* Changed return type to match __builtin_clzl() and reviewed usage.
* Use intrinsics where available.
* Pick a fallback implementation suitable for inlining.