René's URL Explorer Experiment


Title: gh-90716: add _pylong.py module by nascheme · Pull Request #96673 · python/cpython · GitHub

Open Graph Title: gh-90716: add _pylong.py module by nascheme · Pull Request #96673 · python/cpython

X Title: gh-90716: add _pylong.py module by nascheme · Pull Request #96673 · python/cpython

Description: Add Python implementations of certain longobject.c functions. These use asymptotically faster algorithms that can be used for operations on integers with many digits. In those cases, the performance overhead of the Python implementation is not significant since the asymptotic behavior is what dominates runtime. Functions provided by this module should be considered private and not part of any public API. Currently implemented is int_to_decimal_string() (based on code from Tim), int_divmod() (based on code from Mark), and str_to_int() (based on code from bjorn-martinsson). The longobject.c module has been changed to call into _pylong if the Python version is likely to be faster. Examples of performance improvements: int->str python -m timeit -s "i=(1<<2_000_000) - 1" "str(i)" Before: 1 loop, best of 5: 3.58 sec per loop After: 2 loops, best of 5: 168 msec per loop str->int python -m timeit -s "s='1'*1_000_000" "int(s)" Before: 1 loop, best of 5: 3.65 sec per loop After: 1 loop, best of 5: 470 msec per loop divmod python -m timeit -s "a=(1<<20_000_000)-1; b=(1<<100_000)" "divmod(a, b)" Before: 1 loop, best of 5: 2.23 sec per loop After: 2 loops, best of 5: 141 msec per loop Co-author: Tim Peters tim.peters@gmail.com Co-author: Mark Dickinson dickinsm@gmail.com Co-author: Bjorn Martinsson Issue: gh-90716

Open Graph Description: Add Python implementations of certain longobject.c functions. These use asymptotically faster algorithms that can be used for operations on integers with many digits. In those cases, the performan...

X Description: Add Python implementations of certain longobject.c functions. These use asymptotically faster algorithms that can be used for operations on integers with many digits. In those cases, the performan...

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

X: @github

direct link

Domain: github.com

react-profiling0
react-import-mapreact,react-dom,react-dom/client,react-dom/profiling,react-is,react/compiler-runtime,react/jsx-dev-runtime,react/jsx-runtime,scheduler@b8488ee2c322
route-pattern/:user_id/:repository/pull/:id/files(.:format)
route-controllerpull_requests
route-actionfiles
fetch-noncev2:c9dc6350-9dc9-5c48-a24b-dcedaca9baee
current-catalog-service-hashae870bc5e265a340912cde392f23dad3671a0a881730ffdadd82f2f57d81641b
request-id9D44:76F02:3D7FBB0:4E953E3:6B020EF5
html-safe-nonce3f5009a72cd65e47b7414097524c0d1401c8315c34f73920303fb0b0b7eb2fbb
visitor-payloadeyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiI5RDQ0Ojc2RjAyOjNEN0ZCQjA6NEU5NTNFMzo2QjAyMEVGNSIsInZpc2l0b3JfaWQiOiI5MTY5MTk2NDgwODE5NDk4NzQxIiwicmVnaW9uX2VkZ2UiOiJpYWQiLCJyZWdpb25fcmVuZGVyIjoiaWFkIn0=
visitor-hmac99138c39f9927f4ff365dced90f4654af7bd649daab0c5476b74d090f08d559a
hovercard-subject-tagpull_request:1049596149
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/96673/files
twitter:imagehttps://avatars.githubusercontent.com/u/690853?s=400&v=4
twitter:cardsummary_large_image
og:imagehttps://avatars.githubusercontent.com/u/690853?s=400&v=4
og:image:altAdd Python implementations of certain longobject.c functions. These use asymptotically faster algorithms that can be used for operations on integers with many digits. In those cases, the performan...
og:site_nameGitHub
og:typeobject
hostnamegithub.com
expected-hostnamegithub.com
None87e774ee7c6b3bee0490394e4d3e57ec9dbc956f74b87ea685dc8996c1676456
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
release423dbb54c5e7bfecc838eb387c1435eb3d0e760d
ui-targetfull
theme-color#1e2327
color-schemelight dark

Links:

Skip to contenthttps://github.com/python/cpython/pull/96673/files#start-of-content
https://github.com/
Sign inhttps://github.com/login?return_to=https%3A%2F%2Fgithub.com%2Fpython%2Fcpython%2Fpull%2F96673%2Ffiles
GitHubRepository hosting, code review, and collaborationhttps://github.com/platform
CopilotAI coding agent for tasks, projects, and automated workhttps://github.com/features/copilot
ActionsCI/CD and automationhttps://github.com/features/actions
Code QualityQuality analysis, fixes, and enforcementhttps://github.com/features/code-quality
CodespacesCloud development environmentshttps://github.com/features/codespaces
Code SecurityVulnerability detection and remediationhttps://github.com/security/advanced-security/code-security
Secret ProtectionSecret scanning and leak preventionhttps://github.com/security/advanced-security/secret-protection
All Featureshttps://github.com/features
Documentationhttps://docs.github.com/en
Traininghttps://learn.github.com/skills
Certificationshttps://learn.github.com/credentials
Build with Copilothttps://github.com/features/ai
Customize Copilothttps://docs.github.com/en/copilot/how-tos/copilot-on-github/customize-copilot/customize-copilot-overview
Integrationshttps://github.com/marketplace
Trending reposhttps://github.com/trending
GitHub Sponsorshttps://github.com/open-source/sponsors
Developer articleshttps://github.com/resources/articles
ChangelogYour source for the latest features, improvements, and fixes across GitHub products, all in one place.https://github.blog/changelog/
Enterpriseshttps://github.com/enterprise
Teamhttps://github.com/team
Startupshttps://github.com/enterprise/startups
Nonprofitshttps://github.com/solutions/industry/nonprofits
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
See all industrieshttps://github.com/solutions/industry
Why GitHubhttps://github.com/why-github
Customer Storieshttps://github.com/customer-stories
Business insightshttps://github.com/solutions/executive-insights
Trust Centerhttps://github.com/trust-center
GitHub Advanced SecurityEnterprise-grade code securityhttps://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/enterprise/premium-support
Documentationhttps://docs.github.com/en
Resource centerhttps://github.com/resources
Bloghttps://github.blog/
Events & webinarshttps://github.com/resources/events
Community Forumhttps://github.com/orgs/community/discussions
Customer Storieshttps://github.com/customer-stories
Integrationshttps://github.com/marketplace
Customer supporthttps://help.github.com/
Traininghttps://learn.github.com/skills
GitHub Statushttps://www.githubstatus.com/
Abouthttps://github.com/about
Partnershttps://github.com/partners
Changeloghttps://github.blog/changelog/
GitHub UniverseThe event for developers, by developers — talks, workshops, and what’s next for GitHub.https://githubuniverse.com/
Pricinghttps://github.com/pricing
Sign inhttps://github.com/login?return_to=https%3A%2F%2Fgithub.com%2Fpython%2Fcpython%2Fpull%2F96673%2Ffiles
Sign uphttps://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/96673/files
Reloadhttps://github.com/python/cpython/pull/96673/files
Reloadhttps://github.com/python/cpython/pull/96673/files
pythonhttps://github.com/python
cpythonhttps://github.com/python/cpython
Codehttps://github.com/python/cpython
Issues5k+ (5k+)https://github.com/python/cpython/issues
Pull requests2.4k (2.4k)https://github.com/python/cpython/pulls
Actionshttps://github.com/python/cpython/actions
Projectshttps://github.com/python/cpython/projects
Security and qualityhttps://github.com/python/cpython/security
Insightshttps://github.com/python/cpython/insights
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
naschemehttps://github.com/nascheme
python:mainhttps://github.com/python/cpython/tree/main
nascheme:pylong_modulehttps://github.com/nascheme/cpython/tree/pylong_module
Conversation 90 https://github.com/python/cpython/pull/96673
Commits 6 https://github.com/python/cpython/pull/96673/commits
Checks 0 https://github.com/python/cpython/pull/96673/checks
Files changed https://github.com/python/cpython/pull/96673/files
Please reload this pagehttps://github.com/python/cpython/pull/96673/files
gh-90716: add _pylong.py module https://github.com/python/cpython/pull/96673/files#top
Show all changes 6 commits https://github.com/python/cpython/pull/96673/files
136fad2 Add _pylong.py module. nascheme Sep 8, 2022 https://github.com/python/cpython/pull/96673/commits/136fad21aa449058562e242dfa6cab44569f758f
0df1528 Avoid the quadratic behaviour inside _divmod_pos. nascheme Sep 26, 2022 https://github.com/python/cpython/pull/96673/commits/0df15289a8eda3a141394c4a0f24b6e425afd4e1
bd6cd70 Improve comments, remove unneeded case. nascheme Sep 26, 2022 https://github.com/python/cpython/pull/96673/commits/bd6cd7057729d4075a185c9f7757253f8f046cd8
68b1737 Tweak _DIV_LIMIT and improve test. nascheme Sep 26, 2022 https://github.com/python/cpython/pull/96673/commits/68b17374aabcfd87a9aa35998dacc4463f07b0ca
43d61e3 Add divmod_threshold.py script. nascheme Sep 26, 2022 https://github.com/python/cpython/pull/96673/commits/43d61e3cb066cfb08d09cd7d1151862bb056bcc4
ed50a4a Fix error handling in pylong_int_from_string(). nascheme Oct 25, 2022 https://github.com/python/cpython/pull/96673/commits/ed50a4af1850719c47eabc99fb67a8db48099e18
Clear filters https://github.com/python/cpython/pull/96673/files
Please reload this pagehttps://github.com/python/cpython/pull/96673/files
Please reload this pagehttps://github.com/python/cpython/pull/96673/files
_pylong.py https://github.com/python/cpython/pull/96673/files#diff-834cbd887d66d34ac52a94190223faf1bc916ca22cabfb3739b11cec83a65512
test_int.py https://github.com/python/cpython/pull/96673/files#diff-18ccbdfd8076e3f5b7f84f250e7f312799c3db073d3c8e351f5ce4ad18d3c304
2022-09-09-16-32-58.gh-issue-90716.z4yuYq.rst https://github.com/python/cpython/pull/96673/files#diff-a00f46642f1942b90ece5b6d20ae1a6d4c0f690c7e88b64cb64b37b3f48f9806
longobject.c https://github.com/python/cpython/pull/96673/files#diff-1a6e70e2beeecad88840c67284ac4d54a36998029244771fcc820e801390726a
stdlib_module_names.h https://github.com/python/cpython/pull/96673/files#diff-152e0a1d932d06bae2302482de6c49082b62169699729700d445d4f588504af5
divmod_threshold.py https://github.com/python/cpython/pull/96673/files#diff-987e009be46af6c66279805a05a7a9ce8580fd7c316f7316637227934c6a4f35
Lib/_pylong.pyhttps://github.com/python/cpython/pull/96673/files#diff-834cbd887d66d34ac52a94190223faf1bc916ca22cabfb3739b11cec83a65512
View file https://github.com/nascheme/cpython/blob/ed50a4af1850719c47eabc99fb67a8db48099e18/Lib/_pylong.py
Open in desktop https://desktop.github.com
https://github.co/hiddenchars
https://github.com/python/cpython/pull/96673/{{ revealButtonHref }}
Lib/test/test_int.pyhttps://github.com/python/cpython/pull/96673/files#diff-18ccbdfd8076e3f5b7f84f250e7f312799c3db073d3c8e351f5ce4ad18d3c304
View file https://github.com/nascheme/cpython/blob/ed50a4af1850719c47eabc99fb67a8db48099e18/Lib/test/test_int.py
Open in desktop https://desktop.github.com
https://github.co/hiddenchars
https://github.com/python/cpython/pull/96673/{{ revealButtonHref }}
https://github.com/python/cpython/pull/96673/files#diff-18ccbdfd8076e3f5b7f84f250e7f312799c3db073d3c8e351f5ce4ad18d3c304
Misc/NEWS.d/next/Core and Builtins/2022-09-09-16-32-58.gh-issue-90716.z4yuYq.rsthttps://github.com/python/cpython/pull/96673/files#diff-a00f46642f1942b90ece5b6d20ae1a6d4c0f690c7e88b64cb64b37b3f48f9806
View file https://github.com/nascheme/cpython/blob/ed50a4af1850719c47eabc99fb67a8db48099e18/Misc/NEWS.d/next/Core%20and%20Builtins/2022-09-09-16-32-58.gh-issue-90716.z4yuYq.rst
Open in desktop https://desktop.github.com
https://github.co/hiddenchars
https://github.com/python/cpython/pull/96673/{{ revealButtonHref }}
Please reload this pagehttps://github.com/python/cpython/pull/96673/files
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.