René's URL Explorer Experiment


Title: bpo-29782: Consolidate _Py_Bit_Length() by niklasf · Pull Request #20739 · python/cpython · GitHub

Open Graph Title: bpo-29782: Consolidate _Py_Bit_Length() by niklasf · Pull Request #20739 · python/cpython

X Title: bpo-29782: Consolidate _Py_Bit_Length() by niklasf · Pull Request #20739 · python/cpython

Description: 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 (mostly theoretical) fallback implementation suitable for inlining. https://bugs.python.org/issue29782

Open Graph Description: 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...

X Description: 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...

Opengraph URL: https://github.com/python/cpython/pull/20739

X: @github

direct link

Domain: github.com

route-pattern/:user_id/:repository/pull/:id/files(.:format)
route-controllerpull_requests
route-actionfiles
fetch-noncev2:310a7ee2-766d-fe71-dd53-ecd9b0e3cd58
current-catalog-service-hashae870bc5e265a340912cde392f23dad3671a0a881730ffdadd82f2f57d81641b
request-id8D10:21279A:6457F6:813A2D:696B1134
html-safe-nonceeb304fdf1cc3ebfd7902b1260397dd89db63356f7e396237f1615873e14e2ac6
visitor-payloadeyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiI4RDEwOjIxMjc5QTo2NDU3RjY6ODEzQTJEOjY5NkIxMTM0IiwidmlzaXRvcl9pZCI6Ijg5OTkzNzc0NTk2Mzg2MzY4NTIiLCJyZWdpb25fZWRnZSI6ImlhZCIsInJlZ2lvbl9yZW5kZXIiOiJpYWQifQ==
visitor-hmac404086e401960990b2f952b2c14718871caf1b9b1f852b72f0ca2af2618df6b4
hovercard-subject-tagpull_request:431307468
github-keyboard-shortcutsrepository,pull-request-list,pull-request-conversation,pull-request-files-changed,copilot
google-site-verificationApib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I
octolytics-urlhttps://collector.github.com/github/collect
analytics-location///pull_requests/show/files
fb:app_id1401488693436528
apple-itunes-appapp-id=1477376905, app-argument=https://github.com/python/cpython/pull/20739/files
twitter:imagehttps://avatars.githubusercontent.com/u/402777?s=400&v=4
twitter:cardsummary_large_image
og:imagehttps://avatars.githubusercontent.com/u/402777?s=400&v=4
og:image:altIn 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...
og:site_nameGitHub
og:typeobject
hostnamegithub.com
expected-hostnamegithub.com
None5f99f7c1d70f01da5b93e5ca90303359738944d8ab470e396496262c66e60b8d
turbo-cache-controlno-preview
diff-viewunified
go-importgithub.com/python/cpython git https://github.com/python/cpython.git
octolytics-dimension-user_id1525981
octolytics-dimension-user_loginpython
octolytics-dimension-repository_id81598961
octolytics-dimension-repository_nwopython/cpython
octolytics-dimension-repository_publictrue
octolytics-dimension-repository_is_forkfalse
octolytics-dimension-repository_network_root_id81598961
octolytics-dimension-repository_network_root_nwopython/cpython
turbo-body-classeslogged-out env-production page-responsive full-width
disable-turbotrue
browser-stats-urlhttps://api.github.com/_private/browser/stats
browser-errors-urlhttps://api.github.com/_private/browser/errors
release82560a55c6b2054555076f46e683151ee28a19bc
ui-targetfull
theme-color#1e2327
color-schemelight dark

Links:

Skip to contenthttps://github.com/python/cpython/pull/20739/files#start-of-content
https://github.com/
Sign in https://github.com/login?return_to=https%3A%2F%2Fgithub.com%2Fpython%2Fcpython%2Fpull%2F20739%2Ffiles
GitHub CopilotWrite better code with AIhttps://github.com/features/copilot
GitHub SparkBuild and deploy intelligent appshttps://github.com/features/spark
GitHub ModelsManage and compare promptshttps://github.com/features/models
MCP RegistryNewIntegrate external toolshttps://github.com/mcp
ActionsAutomate any workflowhttps://github.com/features/actions
CodespacesInstant dev environmentshttps://github.com/features/codespaces
IssuesPlan and track workhttps://github.com/features/issues
Code ReviewManage code changeshttps://github.com/features/code-review
GitHub Advanced SecurityFind and fix vulnerabilitieshttps://github.com/security/advanced-security
Code securitySecure your code as you buildhttps://github.com/security/advanced-security/code-security
Secret protectionStop leaks before they starthttps://github.com/security/advanced-security/secret-protection
Why GitHubhttps://github.com/why-github
Documentationhttps://docs.github.com
Bloghttps://github.blog
Changeloghttps://github.blog/changelog
Marketplacehttps://github.com/marketplace
View all featureshttps://github.com/features
Enterpriseshttps://github.com/enterprise
Small and medium teamshttps://github.com/team
Startupshttps://github.com/enterprise/startups
Nonprofitshttps://github.com/solutions/industry/nonprofits
App Modernizationhttps://github.com/solutions/use-case/app-modernization
DevSecOpshttps://github.com/solutions/use-case/devsecops
DevOpshttps://github.com/solutions/use-case/devops
CI/CDhttps://github.com/solutions/use-case/ci-cd
View all use caseshttps://github.com/solutions/use-case
Healthcarehttps://github.com/solutions/industry/healthcare
Financial serviceshttps://github.com/solutions/industry/financial-services
Manufacturinghttps://github.com/solutions/industry/manufacturing
Governmenthttps://github.com/solutions/industry/government
View all industrieshttps://github.com/solutions/industry
View all solutionshttps://github.com/solutions
AIhttps://github.com/resources/articles?topic=ai
Software Developmenthttps://github.com/resources/articles?topic=software-development
DevOpshttps://github.com/resources/articles?topic=devops
Securityhttps://github.com/resources/articles?topic=security
View all topicshttps://github.com/resources/articles
Customer storieshttps://github.com/customer-stories
Events & webinarshttps://github.com/resources/events
Ebooks & reportshttps://github.com/resources/whitepapers
Business insightshttps://github.com/solutions/executive-insights
GitHub Skillshttps://skills.github.com
Documentationhttps://docs.github.com
Customer supporthttps://support.github.com
Community forumhttps://github.com/orgs/community/discussions
Trust centerhttps://github.com/trust-center
Partnershttps://github.com/partners
GitHub SponsorsFund open source developershttps://github.com/sponsors
Security Labhttps://securitylab.github.com
Maintainer Communityhttps://maintainers.github.com
Acceleratorhttps://github.com/accelerator
Archive Programhttps://archiveprogram.github.com
Topicshttps://github.com/topics
Trendinghttps://github.com/trending
Collectionshttps://github.com/collections
Enterprise platformAI-powered developer platformhttps://github.com/enterprise
GitHub Advanced SecurityEnterprise-grade security featureshttps://github.com/security/advanced-security
Copilot for BusinessEnterprise-grade AI featureshttps://github.com/features/copilot/copilot-business
Premium SupportEnterprise-grade 24/7 supporthttps://github.com/premium-support
Pricinghttps://github.com/pricing
Search syntax tipshttps://docs.github.com/search-github/github-code-search/understanding-github-code-search-syntax
documentationhttps://docs.github.com/search-github/github-code-search/understanding-github-code-search-syntax
Sign in https://github.com/login?return_to=https%3A%2F%2Fgithub.com%2Fpython%2Fcpython%2Fpull%2F20739%2Ffiles
Sign up https://github.com/signup?ref_cta=Sign+up&ref_loc=header+logged+out&ref_page=%2F%3Cuser-name%3E%2F%3Crepo-name%3E%2Fpull_requests%2Fshow%2Ffiles&source=header-repo&source_repo=python%2Fcpython
Reloadhttps://github.com/python/cpython/pull/20739/files
Reloadhttps://github.com/python/cpython/pull/20739/files
Reloadhttps://github.com/python/cpython/pull/20739/files
python https://github.com/python
cpythonhttps://github.com/python/cpython
Please reload this pagehttps://github.com/python/cpython/pull/20739/files
Notifications https://github.com/login?return_to=%2Fpython%2Fcpython
Fork 33.9k https://github.com/login?return_to=%2Fpython%2Fcpython
Star 71.1k https://github.com/login?return_to=%2Fpython%2Fcpython
Code https://github.com/python/cpython
Issues 5k+ https://github.com/python/cpython/issues
Pull requests 2.1k https://github.com/python/cpython/pulls
Actions https://github.com/python/cpython/actions
Projects 31 https://github.com/python/cpython/projects
Security Uh oh! There was an error while loading. Please reload this page. https://github.com/python/cpython/security
Please reload this pagehttps://github.com/python/cpython/pull/20739/files
Insights https://github.com/python/cpython/pulse
Code https://github.com/python/cpython
Issues https://github.com/python/cpython/issues
Pull requests https://github.com/python/cpython/pulls
Actions https://github.com/python/cpython/actions
Projects https://github.com/python/cpython/projects
Security https://github.com/python/cpython/security
Insights https://github.com/python/cpython/pulse
Sign up for GitHub https://github.com/signup?return_to=%2Fpython%2Fcpython%2Fissues%2Fnew%2Fchoose
terms of servicehttps://docs.github.com/terms
privacy statementhttps://docs.github.com/privacy
Sign inhttps://github.com/login?return_to=%2Fpython%2Fcpython%2Fissues%2Fnew%2Fchoose
vstinnerhttps://github.com/vstinner
python:masterhttps://github.com/python/cpython/tree/master
niklasf:bpo-29782-msbhttps://github.com/niklasf/cpython/tree/bpo-29782-msb
Conversation 39 https://github.com/python/cpython/pull/20739
Commits 21 https://github.com/python/cpython/pull/20739/commits
Checks 0 https://github.com/python/cpython/pull/20739/checks
Files changed https://github.com/python/cpython/pull/20739/files
Please reload this pagehttps://github.com/python/cpython/pull/20739/files
bpo-29782: Consolidate _Py_Bit_Length() https://github.com/python/cpython/pull/20739/files#top
Show all changes 21 commits https://github.com/python/cpython/pull/20739/files
281009c bpo-29782: Consolidate _Py_Bit_Length() niklasf Jun 8, 2020 https://github.com/python/cpython/pull/20739/commits/281009cad94119a78b73302f2b0c3be216f6b26c
65abb83 Specify required gcc version for __builtin_clzl niklasf Jun 8, 2020 https://github.com/python/cpython/pull/20739/commits/65abb8304d41c82efee2f64f2a0d126ed7e3013b
ce45ff2 Fix _BitScanReverse usage niklasf Jun 8, 2020 https://github.com/python/cpython/pull/20739/commits/ce45ff2a8d0a131839942dd78fa0952ccff42bae
6464ca6 Document reason for include niklasf Jun 8, 2020 https://github.com/python/cpython/pull/20739/commits/6464ca6001409512ea15c7d4ea732b4b84a96dfa
0bd4265 Ensure future compatibility niklasf Jun 8, 2020 https://github.com/python/cpython/pull/20739/commits/0bd42652dfed7b06dc0fe9e6732e327b717f1618
fbaca66 Do not try to support GCC < 3.4 niklasf Jun 8, 2020 https://github.com/python/cpython/pull/20739/commits/fbaca66885fdfb64edcbe5ec45ec590405e98e79
436f68b Coding style niklasf Jun 8, 2020 https://github.com/python/cpython/pull/20739/commits/436f68b26f776a5fd80375122c44c00c9710dd70
ac664bc Fix comment indent niklasf Jun 8, 2020 https://github.com/python/cpython/pull/20739/commits/ac664bc555efa89e309e1bfcfd51243ccb055205
3279d17 Do not factor out x != 0 niklasf Jun 8, 2020 https://github.com/python/cpython/pull/20739/commits/3279d1750e25d7589e6f2d92391578ab41d613cb
525da3d Fix and move _Py_bit_length_digit() niklasf Jun 8, 2020 https://github.com/python/cpython/pull/20739/commits/525da3d1f77d0b34a81ad18a32cbf65f3b677eb8
e487622 Add unit test for _Py_bit_length() niklasf Jun 8, 2020 https://github.com/python/cpython/pull/20739/commits/e4876228c203758ee3e512c0dbfe04019901dd9a
a338761 Remove useless cast in test niklasf Jun 8, 2020 https://github.com/python/cpython/pull/20739/commits/a338761dd9d47dec671b1711c526cca551fb2ad5
5a146f7 Use original implementation as fallback niklasf Jun 8, 2020 https://github.com/python/cpython/pull/20739/commits/5a146f7cc3b4377d188463f4134b77524d7c9d39
8e3ce66 Re-enable intrinsics niklasf Jun 8, 2020 https://github.com/python/cpython/pull/20739/commits/8e3ce6615c0f053c5e0186423e59ecfc041095e2
86241f6 Explicitly cast sizeof niklasf Jun 8, 2020 https://github.com/python/cpython/pull/20739/commits/86241f6ecb36e07ba76fc8c1162d76ab3c0e6ac4
c7ccbe2 Better tests niklasf Jun 8, 2020 https://github.com/python/cpython/pull/20739/commits/c7ccbe206269a79fc73c7ab1bfe3183e2a21fc62
dfceaf2 Explain Py_BUILD_ASSERT(sizeof(unsigned long) <= 4) niklasf Jun 8, 2020 https://github.com/python/cpython/pull/20739/commits/dfceaf205ed74b9a229cc92c53d7247ad7c5b9eb
fbf01ae Use volatile so test actually runs intrinsic niklasf Jun 8, 2020 https://github.com/python/cpython/pull/20739/commits/fbf01ae0c98156b3f9692453af6c739dedaf4f14
991622b Remove trailing spaces niklasf Jun 8, 2020 https://github.com/python/cpython/pull/20739/commits/991622b6d5542b9d446aee609a4a70504b5c58a8
462d995 _Py_bit_length_digit -> bit_length_digit niklasf Jun 8, 2020 https://github.com/python/cpython/pull/20739/commits/462d995f073215309cbd9afc1aa93658cf683777
98fc7a8 Fixup test expectations niklasf Jun 8, 2020 https://github.com/python/cpython/pull/20739/commits/98fc7a867ede94c2ba2b2077c4deb0227dc8ce7f
Clear filters https://github.com/python/cpython/pull/20739/files
Please reload this pagehttps://github.com/python/cpython/pull/20739/files
Please reload this pagehttps://github.com/python/cpython/pull/20739/files
pycore_bitutils.h https://github.com/python/cpython/pull/20739/files#diff-475908a2e2415758b364235b5adc05545696e4d0f9265ae2dae34c6ad0e58c50
pymath.h https://github.com/python/cpython/pull/20739/files#diff-a77d4c31a23606144a33f4d9d60f8be59d0cf31a744222b2fed9d81908f01474
_testinternalcapi.c https://github.com/python/cpython/pull/20739/files#diff-687f4a736f1f6ad4b6cd4ff65c8e0113408304e8d65530dbd41b3f59a081a126
mathmodule.c https://github.com/python/cpython/pull/20739/files#diff-5b1186dfcc44670529aa53cb728a1c005f58f38324c24787a49f22cec36841c7
longobject.c https://github.com/python/cpython/pull/20739/files#diff-1a6e70e2beeecad88840c67284ac4d54a36998029244771fcc820e801390726a
pymath.c https://github.com/python/cpython/pull/20739/files#diff-e4e24d2fcfe381dbaf1c626d44488e26e92d5305f6d4684f2413265bd8557c0c
Include/internal/pycore_bitutils.hhttps://github.com/python/cpython/pull/20739/files#diff-475908a2e2415758b364235b5adc05545696e4d0f9265ae2dae34c6ad0e58c50
View file https://github.com/niklasf/cpython/blob/98fc7a867ede94c2ba2b2077c4deb0227dc8ce7f/Include/internal/pycore_bitutils.h
Open in desktop https://desktop.github.com
https://github.co/hiddenchars
https://github.com/python/cpython/pull/20739/{{ revealButtonHref }}
https://github.com/python/cpython/pull/20739/files#diff-475908a2e2415758b364235b5adc05545696e4d0f9265ae2dae34c6ad0e58c50
https://github.com/python/cpython/pull/20739/files#diff-475908a2e2415758b364235b5adc05545696e4d0f9265ae2dae34c6ad0e58c50
https://github.com/python/cpython/pull/20739/files#diff-475908a2e2415758b364235b5adc05545696e4d0f9265ae2dae34c6ad0e58c50
Please reload this pagehttps://github.com/python/cpython/pull/20739/files
Please reload this pagehttps://github.com/python/cpython/pull/20739/files
Please reload this pagehttps://github.com/python/cpython/pull/20739/files
Include/pymath.hhttps://github.com/python/cpython/pull/20739/files#diff-a77d4c31a23606144a33f4d9d60f8be59d0cf31a744222b2fed9d81908f01474
View file https://github.com/niklasf/cpython/blob/98fc7a867ede94c2ba2b2077c4deb0227dc8ce7f/Include/pymath.h
Open in desktop https://desktop.github.com
https://github.co/hiddenchars
https://github.com/python/cpython/pull/20739/{{ revealButtonHref }}
https://github.com/python/cpython/pull/20739/files#diff-a77d4c31a23606144a33f4d9d60f8be59d0cf31a744222b2fed9d81908f01474
Modules/_testinternalcapi.chttps://github.com/python/cpython/pull/20739/files#diff-687f4a736f1f6ad4b6cd4ff65c8e0113408304e8d65530dbd41b3f59a081a126
View file https://github.com/niklasf/cpython/blob/98fc7a867ede94c2ba2b2077c4deb0227dc8ce7f/Modules/_testinternalcapi.c
Open in desktop https://desktop.github.com
https://github.co/hiddenchars
https://github.com/python/cpython/pull/20739/{{ revealButtonHref }}
https://github.com/python/cpython/pull/20739/files#diff-687f4a736f1f6ad4b6cd4ff65c8e0113408304e8d65530dbd41b3f59a081a126
https://github.com/python/cpython/pull/20739/files#diff-687f4a736f1f6ad4b6cd4ff65c8e0113408304e8d65530dbd41b3f59a081a126
https://github.com/python/cpython/pull/20739/files#diff-687f4a736f1f6ad4b6cd4ff65c8e0113408304e8d65530dbd41b3f59a081a126
https://github.com/python/cpython/pull/20739/files#diff-687f4a736f1f6ad4b6cd4ff65c8e0113408304e8d65530dbd41b3f59a081a126
Modules/mathmodule.chttps://github.com/python/cpython/pull/20739/files#diff-5b1186dfcc44670529aa53cb728a1c005f58f38324c24787a49f22cec36841c7
View file https://github.com/niklasf/cpython/blob/98fc7a867ede94c2ba2b2077c4deb0227dc8ce7f/Modules/mathmodule.c
Open in desktop https://desktop.github.com
https://github.co/hiddenchars
https://github.com/python/cpython/pull/20739/{{ revealButtonHref }}
https://github.com/python/cpython/pull/20739/files#diff-5b1186dfcc44670529aa53cb728a1c005f58f38324c24787a49f22cec36841c7
Please reload this pagehttps://github.com/python/cpython/pull/20739/files
https://github.com/python/cpython/pull/20739/files#diff-5b1186dfcc44670529aa53cb728a1c005f58f38324c24787a49f22cec36841c7
Objects/longobject.chttps://github.com/python/cpython/pull/20739/files#diff-1a6e70e2beeecad88840c67284ac4d54a36998029244771fcc820e801390726a
View file https://github.com/niklasf/cpython/blob/98fc7a867ede94c2ba2b2077c4deb0227dc8ce7f/Objects/longobject.c
Open in desktop https://desktop.github.com
https://github.co/hiddenchars
https://github.com/python/cpython/pull/20739/{{ revealButtonHref }}
https://github.com/python/cpython/pull/20739/files#diff-1a6e70e2beeecad88840c67284ac4d54a36998029244771fcc820e801390726a
mdickinsonhttps://github.com/mdickinson
Jun 14, 2020https://github.com/python/cpython/pull/20739/files#r439807531
Learn morehttps://docs.github.com/articles/managing-disruptive-comments/#hiding-a-comment
https://stackoverflow.com/q/3957252/270986https://stackoverflow.com/q/3957252/270986
Please reload this pagehttps://github.com/python/cpython/pull/20739/files
https://github.com/python/cpython/pull/20739/files#diff-1a6e70e2beeecad88840c67284ac4d54a36998029244771fcc820e801390726a
https://github.com/python/cpython/pull/20739/files#diff-1a6e70e2beeecad88840c67284ac4d54a36998029244771fcc820e801390726a
https://github.com/python/cpython/pull/20739/files#diff-1a6e70e2beeecad88840c67284ac4d54a36998029244771fcc820e801390726a
https://github.com/python/cpython/pull/20739/files#diff-1a6e70e2beeecad88840c67284ac4d54a36998029244771fcc820e801390726a
https://github.com/python/cpython/pull/20739/files#diff-1a6e70e2beeecad88840c67284ac4d54a36998029244771fcc820e801390726a
https://github.com/python/cpython/pull/20739/files#diff-1a6e70e2beeecad88840c67284ac4d54a36998029244771fcc820e801390726a
https://github.com/python/cpython/pull/20739/files#diff-1a6e70e2beeecad88840c67284ac4d54a36998029244771fcc820e801390726a
https://github.com/python/cpython/pull/20739/files#diff-1a6e70e2beeecad88840c67284ac4d54a36998029244771fcc820e801390726a
https://github.com/python/cpython/pull/20739/files#diff-1a6e70e2beeecad88840c67284ac4d54a36998029244771fcc820e801390726a
https://github.com/python/cpython/pull/20739/files#diff-1a6e70e2beeecad88840c67284ac4d54a36998029244771fcc820e801390726a
https://github.com/python/cpython/pull/20739/files#diff-1a6e70e2beeecad88840c67284ac4d54a36998029244771fcc820e801390726a
https://github.com/python/cpython/pull/20739/files#diff-1a6e70e2beeecad88840c67284ac4d54a36998029244771fcc820e801390726a
https://github.com/python/cpython/pull/20739/files#diff-1a6e70e2beeecad88840c67284ac4d54a36998029244771fcc820e801390726a
https://github.com/python/cpython/pull/20739/files#diff-1a6e70e2beeecad88840c67284ac4d54a36998029244771fcc820e801390726a
https://github.com/python/cpython/pull/20739/files#diff-1a6e70e2beeecad88840c67284ac4d54a36998029244771fcc820e801390726a
https://github.com/python/cpython/pull/20739/files#diff-1a6e70e2beeecad88840c67284ac4d54a36998029244771fcc820e801390726a
Python/pymath.chttps://github.com/python/cpython/pull/20739/files#diff-e4e24d2fcfe381dbaf1c626d44488e26e92d5305f6d4684f2413265bd8557c0c
View file https://github.com/niklasf/cpython/blob/98fc7a867ede94c2ba2b2077c4deb0227dc8ce7f/Python/pymath.c
Open in desktop https://desktop.github.com
https://github.co/hiddenchars
https://github.com/python/cpython/pull/20739/{{ revealButtonHref }}
https://github.com/python/cpython/pull/20739/files#diff-e4e24d2fcfe381dbaf1c626d44488e26e92d5305f6d4684f2413265bd8557c0c
https://github.com
Termshttps://docs.github.com/site-policy/github-terms/github-terms-of-service
Privacyhttps://docs.github.com/site-policy/privacy-policies/github-privacy-statement
Securityhttps://github.com/security
Statushttps://www.githubstatus.com/
Communityhttps://github.community/
Docshttps://docs.github.com/
Contacthttps://support.github.com?tags=dotcom-footer

Viewport: width=device-width


URLs of crawlers that visited me.