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
Domain: github.com
| route-pattern | /:user_id/:repository/pull/:id/checks(.:format) |
| route-controller | pull_requests |
| route-action | checks |
| fetch-nonce | v2:77cfadae-0cfd-1d2f-7b29-034efb4ac0c0 |
| current-catalog-service-hash | 87dc3bc62d9b466312751bfd5f889726f4f1337bdff4e8be7da7c93d6c00a25a |
| request-id | B80A:D0F38:17A1463:21081A0:696A3637 |
| html-safe-nonce | 1d600dd870c0e3e71604fcecdd8fb893646a1f26fd47e7619c421b757f99f606 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJCODBBOkQwRjM4OjE3QTE0NjM6MjEwODFBMDo2OTZBMzYzNyIsInZpc2l0b3JfaWQiOiIxMDI3MjIzMjQxMTQ0MDIyNTgzIiwicmVnaW9uX2VkZ2UiOiJpYWQiLCJyZWdpb25fcmVuZGVyIjoiaWFkIn0= |
| visitor-hmac | 332ad8b2b9c2e58b84e2c45e73eb36a5202e267780b92fab097172d13756a4a9 |
| hovercard-subject-tag | pull_request:591210909 |
| github-keyboard-shortcuts | repository,pull-request-list,pull-request-conversation,pull-request-files-changed,checks,copilot |
| google-site-verification | Apib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I |
| octolytics-url | https://collector.github.com/github/collect |
| analytics-location | / |
| fb:app_id | 1401488693436528 |
| apple-itunes-app | app-id=1477376905, app-argument=https://github.com/python/cpython/pull/24828/checks |
| twitter:image | https://avatars.githubusercontent.com/u/1152074?s=400&v=4 |
| twitter:card | summary_large_image |
| og:image | https://avatars.githubusercontent.com/u/1152074?s=400&v=4 |
| og:image:alt | 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... |
| og:site_name | GitHub |
| og:type | object |
| hostname | github.com |
| expected-hostname | github.com |
| None | 321736bfdb3f591415ae895a0459bec204b26a76caf47ba5c980634cfacc4538 |
| turbo-cache-control | no-preview |
| go-import | github.com/python/cpython git https://github.com/python/cpython.git |
| octolytics-dimension-user_id | 1525981 |
| octolytics-dimension-user_login | python |
| octolytics-dimension-repository_id | 81598961 |
| octolytics-dimension-repository_nwo | python/cpython |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 81598961 |
| octolytics-dimension-repository_network_root_nwo | python/cpython |
| turbo-body-classes | logged-out env-production page-responsive full-width full-width-p-0 |
| disable-turbo | false |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | 7a9163cefd1ea4bd06f8eb7c082f43e4e53f626f |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
Links:
Viewport: width=device-width