-
-
Notifications
You must be signed in to change notification settings - Fork 30.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Docs] Possibly Add More Information About Immortal Objects #120426
Comments
FWIW, I'm hesitant to make immortal objects more prominent in the docs. Presently they are an internal implementation detail (which daring users may use at their own risk). If anything, I'd rather they were less prominent in the docs. The only reason to mention them in the docs at all is for the benefit of people that notice objects with a really big refcount (which always stays the same). All that would change, of course, if we were to expose immortal objects via public API--which PEP 683 purposefully did not do (other than the slight change in semantics for a few refcount operations). However, I'm not sure the existing internal API should ever be made public. It would be a genuine foot gun in its current unconstrained and unmanaged form, inviting substantial memory leaks. At best we might eventually choose to expose some more-carefully-crafted variant that's either better constrained in scope, less generic, or better managed by the runtime (or all of those). Until then, I think we should avoid drawing people's attention to the concept/term. |
It's mainly conceptual documentation that I was suggesting would be helpful, rather than getting into the exact mechanics. At the very least, a glossary entry for other documentation like https://docs.python.org/3/library/sys.html#sys.getrefcount and https://docs.python.org/3/glossary.html#term-reference-count to point to rather than each mention having to provide its own short definition. I don't think the actual definition needs to be particularly in depth, just give a bit more info about why immortal objects are a thing:
And then tweak the "historical document" notice on the PEP to make it clear that while it may no longer be an accurate description of the technical implementation details, it will indefinitely provide an accurate description of the benefits of including immortal objects in the CPython implementation. |
I'm in favor of this definition, but would say "may not report" instead of "does not report". |
I agree with @ericsnowcurrently's proposal of keeping this mostly as an implementation detail since that was the original intent of the PEP. At the same time, @ncoghlan is very explicitly stating that it's an implementation detail so I wouldn't be opposed to that. I'll leave it to Eric to ultimately decide |
(Sorry, I closed the wrong issue) |
I think we can all agree the current entry for “immortal” is not OK. IMO, it should be kept in some form -- users do run into immortal objects and end up surprised. But it should be marked as a CPython implementation detail. |
When wording this, I wanted to add something like the following, to answer an obvious question users might have:
But, I see that for free-threading builds, @colesbury, is that intended to be a public API contract? Is I'd expect a note for
cc @vstinner |
I sent a PR without a “no mechanism” line. I plan to merge it ~ Friday if there are no objections. |
Reword the glossary term "immortal", mark it as an implementation detail
Reword the glossary term "immortal", mark it as an implementation detail (cherry picked from commit 6754566)
…3191) (python#123491) Add the glossary term "immortal", mark it as an implementation detail (cherry picked from commit 6754566) (cherry picked from commit 1af74fa) (Unlike the original commits, this adds the entire entry.)
From @ncoghlan in python/peps#3817 (comment):
Linked PRs
The text was updated successfully, but these errors were encountered: