René's URL Explorer Experiment


Title: The C-API for Python to C integer conversion is, to be frank, a mess. · Issue #102471 · python/cpython · GitHub

Open Graph Title: The C-API for Python to C integer conversion is, to be frank, a mess. · Issue #102471 · python/cpython

X Title: The C-API for Python to C integer conversion is, to be frank, a mess. · Issue #102471 · python/cpython

Description: The C-API has built up over 30 years, in a haphazard way. So, it is no surprise that it is a bit of a mess. What makes it worse is that it is based around the C long type, which is varies in size between architectures and operating syste...

Open Graph Description: The C-API has built up over 30 years, in a haphazard way. So, it is no surprise that it is a bit of a mess. What makes it worse is that it is based around the C long type, which is varies in size b...

X Description: The C-API has built up over 30 years, in a haphazard way. So, it is no surprise that it is a bit of a mess. What makes it worse is that it is based around the C long type, which is varies in size b...

Opengraph URL: https://github.com/python/cpython/issues/102471

X: @github

direct link

Domain: github.com


Hey, it has json ld scripts:
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"The C-API for Python to C integer conversion is, to be frank, a mess.","articleBody":"The C-API has built up over 30 years, in a haphazard way. So, it is no surprise that it is a bit of a mess.\r\nWhat makes it worse is that it is based around the C `long` type, which is varies in size between architectures and operating systems in odd ways.\r\nC `long`s are 32 bit on (almost?) all 32 bit machines, 64 bit on most 64 bit machines, except Windows when C `long`s are 32 bits on 64 bit machines. In other words, it is not a useful fixed size, like `int32_t`, nor does match the machine word size, like `intptr_t`.\r\n\r\nWe need a more consistent API for converting from Python integers to C integers and back again.\r\nWe should support both 32 bit and word size C integers. 32 bit, because we often want to store 32 bit values to save space on 64 bit machines, or for portability. We also want to support word size integers for performance and ease of coding.\r\n\r\nThis means we want 4 functions (2 sizes, 2 directions) to convert between C and Python integers.\r\n\r\nCurrently we have:\r\n\r\nWidth    | Py -\u003e C  |  C -\u003e Py \r\n  ---  |  --- | ----\r\n32 bit |   Missing*  |  Missing\r\nMachine word |  Missing* | `PyLong_FromSsize_t` | \r\n\r\nThe C API has a function to convert Python ints to `intptr_t`, but it is missing efficient overflow handling.\r\nIt also has a function with efficient overflow handling, `PyLong_AsLongAndOverflow`, but that returns a `long`.\r\n\r\nHere's what we want:\r\n\r\nWidth    | Py -\u003e C  |  C -\u003e Py \r\n  ---  |  --- | ----\r\n32 bit |  `PyInt_AsInt32` |  `PyInt_FromInt32`\r\nMachine word |  `PyInt_AsSsize_t` | `PyInt_FromSsize_t` | \r\n\r\nI'm using `PyInt` prefix, now that Python 2 is history. It makes it clearer what is the new API.\r\n\r\nNote that I'm not handling unsigned values. I think the extra bit of precision is not worth the complexity of a larger API.\r\nAnd if we decide that they are, we can always add them later.\r\n\r\n\r\n\n\n\u003c!-- gh-linked-prs --\u003e\n### Linked PRs\n* gh-121339\n* gh-127925\n* gh-128267\n* gh-129338\n* gh-129339\n\u003c!-- /gh-linked-prs --\u003e\n","author":{"url":"https://github.com/markshannon","@type":"Person","name":"markshannon"},"datePublished":"2023-03-06T15:00:09.000Z","interactionStatistic":{"@type":"InteractionCounter","interactionType":"https://schema.org/CommentAction","userInteractionCount":10},"url":"https://github.com/102471/cpython/issues/102471"}

route-pattern/_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format)
route-controllervoltron_issues_fragments
route-actionissue_layout
fetch-noncev2:b164ef53-3217-c1d0-a89a-75da50708804
current-catalog-service-hash81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114
request-idD520:3367CB:A0E37:E3276:696A5F47
html-safe-nonceb661868b0532281dae5d403ce039e0aeeec9a1617f43e19bcb85f6891ae02508
visitor-payloadeyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJENTIwOjMzNjdDQjpBMEUzNzpFMzI3Njo2OTZBNUY0NyIsInZpc2l0b3JfaWQiOiI4NjUwMzQ5NTE5MzA5NTI4OTAzIiwicmVnaW9uX2VkZ2UiOiJpYWQiLCJyZWdpb25fcmVuZGVyIjoiaWFkIn0=
visitor-hmace9d9761bbe93cb95c82e3afbb5b78ac5e40227442a51694757090d48588f719e
hovercard-subject-tagissue:1611612427
github-keyboard-shortcutsrepository,issues,copilot
google-site-verificationApib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I
octolytics-urlhttps://collector.github.com/github/collect
analytics-location///voltron/issues_fragments/issue_layout
fb:app_id1401488693436528
apple-itunes-appapp-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/python/cpython/102471/issue_layout
twitter:imagehttps://opengraph.githubassets.com/237e48ad464580337c5a404c438e5d990feb4c93080f261a125bb7ecb0c87bc7/python/cpython/issues/102471
twitter:cardsummary_large_image
og:imagehttps://opengraph.githubassets.com/237e48ad464580337c5a404c438e5d990feb4c93080f261a125bb7ecb0c87bc7/python/cpython/issues/102471
og:image:altThe C-API has built up over 30 years, in a haphazard way. So, it is no surprise that it is a bit of a mess. What makes it worse is that it is based around the C long type, which is varies in size b...
og:image:width1200
og:image:height600
og:site_nameGitHub
og:typeobject
og:author:usernamemarkshannon
hostnamegithub.com
expected-hostnamegithub.com
None9b7735a184970dd9333b2cbe036c8f3c0a9108c64aaa93827c5a64fc70993392
turbo-cache-controlno-preview
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
disable-turbofalse
browser-stats-urlhttps://api.github.com/_private/browser/stats
browser-errors-urlhttps://api.github.com/_private/browser/errors
release87cbd411c2982752221b5751d583a515b23bf5fa
ui-targetfull
theme-color#1e2327
color-schemelight dark

Links:

Skip to contenthttps://github.com/python/cpython/issues/102471#start-of-content
https://github.com/
Sign in https://github.com/login?return_to=https%3A%2F%2Fgithub.com%2Fpython%2Fcpython%2Fissues%2F102471
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%2Fissues%2F102471
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%2Fvoltron%2Fissues_fragments%2Fissue_layout&source=header-repo&source_repo=python%2Fcpython
Reloadhttps://github.com/python/cpython/issues/102471
Reloadhttps://github.com/python/cpython/issues/102471
Reloadhttps://github.com/python/cpython/issues/102471
python https://github.com/python
cpythonhttps://github.com/python/cpython
Please reload this pagehttps://github.com/python/cpython/issues/102471
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/issues/102471
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
New issuehttps://github.com/login?return_to=https://github.com/python/cpython/issues/102471
New issuehttps://github.com/login?return_to=https://github.com/python/cpython/issues/102471
The C-API for Python to C integer conversion is, to be frank, a mess.https://github.com/python/cpython/issues/102471#top
interpreter-core(Objects, Python, Grammar, and Parser dirs)https://github.com/python/cpython/issues?q=state%3Aopen%20label%3A%22interpreter-core%22
type-featureA feature request or enhancementhttps://github.com/python/cpython/issues?q=state%3Aopen%20label%3A%22type-feature%22
https://github.com/markshannon
https://github.com/markshannon
markshannonhttps://github.com/markshannon
on Mar 6, 2023https://github.com/python/cpython/issues/102471#issue-1611612427
gh-102471, PEP 757: Add PyLong import and export API #121339https://github.com/python/cpython/pull/121339
gh-127937: convert decimal module to use import API for ints (PEP 757) #127925https://github.com/python/cpython/pull/127925
gh-102471: convert decimal module to use PyLong_Export API (PEP 757) #128267https://github.com/python/cpython/pull/128267
gh-102471: Credit Sergey B Kirpichev for PEP 757 #129338https://github.com/python/cpython/pull/129338
gh-102471: Change PyLongWriter_Discard(NULL) to do nothing #129339https://github.com/python/cpython/pull/129339
interpreter-core(Objects, Python, Grammar, and Parser dirs)https://github.com/python/cpython/issues?q=state%3Aopen%20label%3A%22interpreter-core%22
type-featureA feature request or enhancementhttps://github.com/python/cpython/issues?q=state%3Aopen%20label%3A%22type-feature%22
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.