Title: Add an API for determining if an object is immortal · Issue #128509 · python/cpython · GitHub
Open Graph Title: Add an API for determining if an object is immortal · Issue #128509 · python/cpython
X Title: Add an API for determining if an object is immortal · Issue #128509 · python/cpython
Description: Feature or enhancement Proposal: Immortal objects might lead to some unexpected results for users that are (unfortunately) messing with reference count details, as seen in #127191; but currently, there's no way to determine what objects ...
Open Graph Description: Feature or enhancement Proposal: Immortal objects might lead to some unexpected results for users that are (unfortunately) messing with reference count details, as seen in #127191; but currently, t...
X Description: Feature or enhancement Proposal: Immortal objects might lead to some unexpected results for users that are (unfortunately) messing with reference count details, as seen in #127191; but currently, t...
Opengraph URL: https://github.com/python/cpython/issues/128509
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Add an API for determining if an object is immortal","articleBody":"# Feature or enhancement\n\n### Proposal:\n\nImmortal objects might lead to some unexpected results for users that are (unfortunately) messing with reference count details, as seen in #127191; but currently, there's no way to determine what objects are actually immortal. \n\nImmortality is an implementation detail, but it still does affect reference counting, and given that it's not very safe to rely on very specific reference counts, we don't want the only way to check for immortality to be via `sys.getrefcount`. So, given that we already have [sys._is_interned](https://docs.python.org/3/library/sys.html#sys._is_interned), it seems fitting to add a `sys._is_immortal` alongside it. \n\nIf we go with this, I think it's also a good idea to note it in some of the documentation. For example, `sys.getrefcount` says this:\n\n\u003e some objects are [immortal](https://docs.python.org/3/glossary.html#term-immortal) and have a very high refcount that does not reflect the actual number of references.\n\nHere, it might be a good idea to mention my proposed `sys._is_immortal`, so there's less ambiguity about the returned value.\n\ncc @erlend-aasland\n\n### Has this already been discussed elsewhere?\n\nNo response given\n\n### Links to previous discussion of this feature:\n\n_No response_\n\n\u003c!-- gh-linked-prs --\u003e\n### Linked PRs\n* gh-128510\n* gh-129182\n\u003c!-- /gh-linked-prs --\u003e\n","author":{"url":"https://github.com/ZeroIntensity","@type":"Person","name":"ZeroIntensity"},"datePublished":"2025-01-05T01:39:18.000Z","interactionStatistic":{"@type":"InteractionCounter","interactionType":"https://schema.org/CommentAction","userInteractionCount":4},"url":"https://github.com/128509/cpython/issues/128509"}
| route-pattern | /_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format) |
| route-controller | voltron_issues_fragments |
| route-action | issue_layout |
| fetch-nonce | v2:cb20eba8-f883-ab5b-86f0-9ab077217f3e |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | EE14:26CA52:3F4000:58DD40:696A0AA7 |
| html-safe-nonce | 01b80b5d604f75652b8c471aaed6a06ed01706b43950f2f81a4e787b336b2d6d |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJFRTE0OjI2Q0E1MjozRjQwMDA6NThERDQwOjY5NkEwQUE3IiwidmlzaXRvcl9pZCI6IjM3MTc3OTQxNDc4Mjk2ODA4MDciLCJyZWdpb25fZWRnZSI6ImlhZCIsInJlZ2lvbl9yZW5kZXIiOiJpYWQifQ== |
| visitor-hmac | 7093332b2560a6e8bd6e1e8c6919b4537bf89cd6f66440d3c1cbe9b6366f9e85 |
| hovercard-subject-tag | issue:2769071430 |
| github-keyboard-shortcuts | repository,issues,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/_view_fragments/issues/show/python/cpython/128509/issue_layout |
| twitter:image | https://opengraph.githubassets.com/28a285d688cb29629832fda8c98a18df53bfa3d038431e94f52d39e12b0e6f4c/python/cpython/issues/128509 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/28a285d688cb29629832fda8c98a18df53bfa3d038431e94f52d39e12b0e6f4c/python/cpython/issues/128509 |
| og:image:alt | Feature or enhancement Proposal: Immortal objects might lead to some unexpected results for users that are (unfortunately) messing with reference count details, as seen in #127191; but currently, t... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | ZeroIntensity |
| hostname | github.com |
| expected-hostname | github.com |
| None | 699227a00bbb7fe1eec276d2ae1c3a93068bc5ba483bd9dc4b2a27a8f4f2f595 |
| 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 |
| disable-turbo | false |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | 7266b2d935baa1c6474b16dd9feaa5ca30607261 |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
Links:
Viewport: width=device-width