]> git.ipfire.org Git - thirdparty/Python/cpython.git/commit
bpo-29782: Consolidate _Py_Bit_Length() (GH-20739)
authorNiklas Fiekas <niklas.fiekas@backscattering.de>
Mon, 15 Jun 2020 12:33:48 +0000 (14:33 +0200)
committerGitHub <noreply@github.com>
Mon, 15 Jun 2020 12:33:48 +0000 (14:33 +0200)
commit794e7d1ab2d7afe70fe0dd87ca8174ac860413e4
tree48ad4d0b5a06b4f80706b16e6ca069f660b25414
parent25f38d7044a3a47465edd851c4e04f337b2c4b9b
bpo-29782: Consolidate _Py_Bit_Length() (GH-20739)

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.
Include/internal/pycore_bitutils.h
Include/pymath.h
Modules/_testinternalcapi.c
Modules/mathmodule.c
Objects/longobject.c
Python/pymath.c