René's URL Explorer Experiment


Title: bpo-43503: Make limited API objects effectively immutable. by ericsnowcurrently · Pull Request #24828 · python/cpython · GitHub

Open Graph Title: bpo-43503: Make limited API objects effectively immutable. by ericsnowcurrently · Pull Request #24828 · python/cpython

X Title: bpo-43503: Make limited API objects effectively immutable. by ericsnowcurrently · Pull Request #24828 · python/cpython

Description: This is a slight alternative to @eduardo-elizondo's GH-19474, though our main motivations are different. Eddie is looking to optionally reduce the impact of refcounts on the copy-on-write semantics of forking. My interest lies in supporting (immutable) objects that can be safely shared between interpreters without a shared GIL. In the short term this will help solve the problem of what to do about PyObjects that are part of the public C-API (and especially the limited API): the singletons and many static types (including the exception types). The problem of those public objects is something I was thinking through last December. This approach using refcounts is one of several I tried. A couple weeks later I found Eddie's PR and adopted a few of his changes (e.g. the high positive bit, whereas I was previously using a negative value). Notable differences from GH-19474: CPU performance isn't impacted (no changes to _Py_INCREF() or Py_DECREF()) set the initial refcount for immortal objects to a value above the magic bit, rather than at it the actual value is halfway between the magic bit and the next bit up, to preserve the magic bit through normal incr/decr the API is opt-in for the public API (but never the limited API), if _Py_IMMORTAL_OBJECTS is defined all the builtin types are made immortal during runtime initialization instead of statically Also note that if Py_IMMORTAL_CONST_REFCOUNTS is defined then the refcount of immortal objects essentially becomes immutable, as in GH-19474. That should meet Eddie's needs without being invasive. UPDATE: I've dropped the "const refcounts" and "opt-in API" parts. See #24828 (comment) for a more in-depth explanation of the motivation (and rationale) for this PR. https://bugs.python.org/issue43503

Open Graph Description: This is a slight alternative to @eduardo-elizondo's GH-19474, though our main motivations are different. Eddie is looking to optionally reduce the impact of refcounts on the copy-on-write sema...

X Description: This is a slight alternative to @eduardo-elizondo's GH-19474, though our main motivations are different. Eddie is looking to optionally reduce the impact of refcounts on the copy-on-write ...

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

X: @github

direct link

Domain: github.com

route-pattern/:user_id/:repository/pull/:id/files(.:format)
route-controllerpull_requests
route-actionfiles
fetch-noncev2:44dfce56-cdc7-87fe-2913-ba381149e180
current-catalog-service-hashae870bc5e265a340912cde392f23dad3671a0a881730ffdadd82f2f57d81641b
request-idBB72:3372CB:DC07D2:130EC93:696A847F
html-safe-noncef1b5e81147232ccc926b07817ba2fa37fa8ab843b70c591f80bad065893afccf
visitor-payloadeyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJCQjcyOjMzNzJDQjpEQzA3RDI6MTMwRUM5Mzo2OTZBODQ3RiIsInZpc2l0b3JfaWQiOiI3NTIxMjkyMjQwMjczNzA0MDYzIiwicmVnaW9uX2VkZ2UiOiJpYWQiLCJyZWdpb25fcmVuZGVyIjoiaWFkIn0=
visitor-hmac2e2dfad949f6f275bad7e76cc5edc7b7d1049c489fe89e118eaf63c72b809f2d
hovercard-subject-tagpull_request:591210909
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/24828/files
twitter:imagehttps://avatars.githubusercontent.com/u/1152074?s=400&v=4
twitter:cardsummary_large_image
og:imagehttps://avatars.githubusercontent.com/u/1152074?s=400&v=4
og:image:altThis is a slight alternative to @eduardo-elizondo's GH-19474, though our main motivations are different. Eddie is looking to optionally reduce the impact of refcounts on the copy-on-write sema...
og:site_nameGitHub
og:typeobject
hostnamegithub.com
expected-hostnamegithub.com
None913560fa317c3c5a71e34f9b19253c9f09d02b4b958a86c2a56f4c8541116377
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
release5998c30593994bf2589055aef7b22d368a499367
ui-targetfull
theme-color#1e2327
color-schemelight dark

Links:

Skip to contenthttps://github.com/python/cpython/pull/24828/files#start-of-content
https://github.com/
Sign in https://github.com/login?return_to=https%3A%2F%2Fgithub.com%2Fpython%2Fcpython%2Fpull%2F24828%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%2F24828%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/24828/files
Reloadhttps://github.com/python/cpython/pull/24828/files
Reloadhttps://github.com/python/cpython/pull/24828/files
python https://github.com/python
cpythonhttps://github.com/python/cpython
Please reload this pagehttps://github.com/python/cpython/pull/24828/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/24828/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
ericsnowcurrentlyhttps://github.com/ericsnowcurrently
python:masterhttps://github.com/python/cpython/tree/master
ericsnowcurrently:globals-immortal-objects-flagshttps://github.com/ericsnowcurrently/cpython/tree/globals-immortal-objects-flags
Conversation 50 https://github.com/python/cpython/pull/24828
Commits 16 https://github.com/python/cpython/pull/24828/commits
Checks 0 https://github.com/python/cpython/pull/24828/checks
Files changed https://github.com/python/cpython/pull/24828/files
Please reload this pagehttps://github.com/python/cpython/pull/24828/files
bpo-43503: Make limited API objects effectively immutable. https://github.com/python/cpython/pull/24828/files#top
Show all changes 16 commits https://github.com/python/cpython/pull/24828/files
4951703 Add support for immortal objects (large neg int means "immortal"). ericsnowcurrently Dec 10, 2020 https://github.com/python/cpython/pull/24828/commits/4951703306d9852f8bc50248dc0966a9ef86feca
4b1eea3 Switch to a positive number. ericsnowcurrently Dec 10, 2020 https://github.com/python/cpython/pull/24828/commits/4b1eea38e5fcc34c98390308bc72e95a0ee59acd
a34f285 Add Py_IMMORTAL_CONST_REFCOUNTS. ericsnowcurrently Dec 10, 2020 https://github.com/python/cpython/pull/24828/commits/a34f2856bbe68a19b564161a95b8cbbc49e38105
3966551 Add a NEWS entry. ericsnowcurrently Mar 11, 2021 https://github.com/python/cpython/pull/24828/commits/3966551811e7f30d9fdc5cc015ea764e11a1f7b4
1a3b4da Add docs. ericsnowcurrently Mar 11, 2021 https://github.com/python/cpython/pull/24828/commits/1a3b4dabf448f0cce2b5513ff35e97c037e032c1
728f24b Drop special handling of negative refcounts. ericsnowcurrently Mar 11, 2021 https://github.com/python/cpython/pull/24828/commits/728f24bb47d167b024a80400b14b4d53512595f7
2536e8b Do not reset the refcount in _PyObject_IsImmortal(). ericsnowcurrently Mar 11, 2021 https://github.com/python/cpython/pull/24828/commits/2536e8b45f4eae343b91f29a13f626ffc1dd555a
518e9e8 Do not allow immortal objects in the limited API. ericsnowcurrently Mar 11, 2021 https://github.com/python/cpython/pull/24828/commits/518e9e84f6eee25be38369ea48825620fa68b953
277e1ea Do not re-declare _PyObject_IsImmortal. ericsnowcurrently Mar 11, 2021 https://github.com/python/cpython/pull/24828/commits/277e1ea1f3996f15dfda3f44c9a495ca3c224616
edef342 Go back to using Py_SET_REFCNT() in _Py_NewReference(). ericsnowcurrently Mar 12, 2021 https://github.com/python/cpython/pull/24828/commits/edef3429eb9c45a8ef139398cc57f3414e880f8b
4d22e00 Fix an accidental line removal. ericsnowcurrently Mar 12, 2021 https://github.com/python/cpython/pull/24828/commits/4d22e00271999d64dbb5f278f1a4d7c210686e11
838f88f Add more comments and drop the internal-only macros from the docs. ericsnowcurrently Mar 12, 2021 https://github.com/python/cpython/pull/24828/commits/838f88fc135ff7a7bcb7fe1f12377991fb594717
00948a0 Drop a holdover from immortal objects with negative refcounts. ericsnowcurrently Mar 15, 2021 https://github.com/python/cpython/pull/24828/commits/00948a007b7316242e489bfdc7d2bd60dfa1505c
00504d9 Move _Py_SET_REFCNT() out of the header file. ericsnowcurrently Mar 15, 2021 https://github.com/python/cpython/pull/24828/commits/00504d974d492b66619380419f749c1f37e31509
e6fc84f Define _py_is_immortal() only for Py_IMMORTAL_CONST_REFCOUNTS. ericsnowcurrently Mar 15, 2021 https://github.com/python/cpython/pull/24828/commits/e6fc84f35290a8254e0e2eaecb502954cf0ab9a0
f103804 Drop Py_IMMORTAL_CONST_REFCOUNTS and make immortal objects internal. ericsnowcurrently Mar 12, 2021 https://github.com/python/cpython/pull/24828/commits/f103804a1fb16d42afd91e420e8e66707ae7adc1
Clear filters https://github.com/python/cpython/pull/24828/files
Please reload this pagehttps://github.com/python/cpython/pull/24828/files
Please reload this pagehttps://github.com/python/cpython/pull/24828/files
pycore_object.h https://github.com/python/cpython/pull/24828/files#diff-2a12f738a77b362d74a65949b58c37f2affcd15ba8b1c979b63bd00223b8a456
object.h https://github.com/python/cpython/pull/24828/files#diff-87272721a5cf1cd9915d6f503f6a7bbefa2f26c935c7ce83ca78706afd0ad05a
2021-03-11-13-03-15.bpo-40255._1LfiG.rst https://github.com/python/cpython/pull/24828/files#diff-14c2226e248223eef759b542f0792ddaf5405e0952da00acc5637faad88d81c8
object.c https://github.com/python/cpython/pull/24828/files#diff-ba56d44ce0dd731d979970b966fde9d8dd15d12a82f727a052a8ad48d4a49363
Include/internal/pycore_object.hhttps://github.com/python/cpython/pull/24828/files#diff-2a12f738a77b362d74a65949b58c37f2affcd15ba8b1c979b63bd00223b8a456
View file https://github.com/ericsnowcurrently/cpython/blob/f103804a1fb16d42afd91e420e8e66707ae7adc1/Include/internal/pycore_object.h
Open in desktop https://desktop.github.com
https://github.co/hiddenchars
https://github.com/python/cpython/pull/24828/{{ revealButtonHref }}
https://github.com/python/cpython/pull/24828/files#diff-2a12f738a77b362d74a65949b58c37f2affcd15ba8b1c979b63bd00223b8a456
vstinnerhttps://github.com/vstinner
Mar 13, 2021https://github.com/python/cpython/pull/24828/files#r593754240
Learn morehttps://docs.github.com/articles/managing-disruptive-comments/#hiding-a-comment
Please reload this pagehttps://github.com/python/cpython/pull/24828/files
ericsnowcurrentlyhttps://github.com/ericsnowcurrently
Mar 15, 2021https://github.com/python/cpython/pull/24828/files#r594483911
Learn morehttps://docs.github.com/articles/managing-disruptive-comments/#hiding-a-comment
Please reload this pagehttps://github.com/python/cpython/pull/24828/files
https://github.com/python/cpython/pull/24828/files#diff-2a12f738a77b362d74a65949b58c37f2affcd15ba8b1c979b63bd00223b8a456
Include/object.hhttps://github.com/python/cpython/pull/24828/files#diff-87272721a5cf1cd9915d6f503f6a7bbefa2f26c935c7ce83ca78706afd0ad05a
View file https://github.com/ericsnowcurrently/cpython/blob/f103804a1fb16d42afd91e420e8e66707ae7adc1/Include/object.h
Open in desktop https://desktop.github.com
https://github.co/hiddenchars
https://github.com/python/cpython/pull/24828/{{ revealButtonHref }}
https://github.com/python/cpython/pull/24828/files#diff-87272721a5cf1cd9915d6f503f6a7bbefa2f26c935c7ce83ca78706afd0ad05a
https://github.com/python/cpython/pull/24828/files#diff-87272721a5cf1cd9915d6f503f6a7bbefa2f26c935c7ce83ca78706afd0ad05a
https://github.com/python/cpython/pull/24828/files#diff-87272721a5cf1cd9915d6f503f6a7bbefa2f26c935c7ce83ca78706afd0ad05a
https://github.com/python/cpython/pull/24828/files#diff-87272721a5cf1cd9915d6f503f6a7bbefa2f26c935c7ce83ca78706afd0ad05a
Misc/NEWS.d/next/Core and Builtins/2021-03-11-13-03-15.bpo-40255._1LfiG.rsthttps://github.com/python/cpython/pull/24828/files#diff-14c2226e248223eef759b542f0792ddaf5405e0952da00acc5637faad88d81c8
View file https://github.com/ericsnowcurrently/cpython/blob/f103804a1fb16d42afd91e420e8e66707ae7adc1/Misc/NEWS.d/next/Core%20and%20Builtins/2021-03-11-13-03-15.bpo-40255._1LfiG.rst
Open in desktop https://desktop.github.com
https://github.co/hiddenchars
https://github.com/python/cpython/pull/24828/{{ revealButtonHref }}
Objects/object.chttps://github.com/python/cpython/pull/24828/files#diff-ba56d44ce0dd731d979970b966fde9d8dd15d12a82f727a052a8ad48d4a49363
View file https://github.com/ericsnowcurrently/cpython/blob/f103804a1fb16d42afd91e420e8e66707ae7adc1/Objects/object.c
Open in desktop https://desktop.github.com
https://github.co/hiddenchars
https://github.com/python/cpython/pull/24828/{{ revealButtonHref }}
https://github.com/python/cpython/pull/24828/files#diff-ba56d44ce0dd731d979970b966fde9d8dd15d12a82f727a052a8ad48d4a49363
https://github.com/python/cpython/pull/24828/files#diff-ba56d44ce0dd731d979970b966fde9d8dd15d12a82f727a052a8ad48d4a49363
https://github.com/python/cpython/pull/24828/files#diff-ba56d44ce0dd731d979970b966fde9d8dd15d12a82f727a052a8ad48d4a49363
vstinnerhttps://github.com/vstinner
Mar 13, 2021https://github.com/python/cpython/pull/24828/files#r593754963
Learn morehttps://docs.github.com/articles/managing-disruptive-comments/#hiding-a-comment
Please reload this pagehttps://github.com/python/cpython/pull/24828/files
gpsheadhttps://github.com/gpshead
Mar 14, 2021https://github.com/python/cpython/pull/24828/files#r593952392
Learn morehttps://docs.github.com/articles/managing-disruptive-comments/#hiding-a-comment
Please reload this pagehttps://github.com/python/cpython/pull/24828/files
ericsnowcurrentlyhttps://github.com/ericsnowcurrently
Mar 15, 2021https://github.com/python/cpython/pull/24828/files#r594484838
Learn morehttps://docs.github.com/articles/managing-disruptive-comments/#hiding-a-comment
Please reload this pagehttps://github.com/python/cpython/pull/24828/files
https://github.com/python/cpython/pull/24828/files#diff-ba56d44ce0dd731d979970b966fde9d8dd15d12a82f727a052a8ad48d4a49363
https://github.com/python/cpython/pull/24828/files#diff-ba56d44ce0dd731d979970b966fde9d8dd15d12a82f727a052a8ad48d4a49363
https://github.com/python/cpython/pull/24828/files#diff-ba56d44ce0dd731d979970b966fde9d8dd15d12a82f727a052a8ad48d4a49363
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.