-
-
Notifications
You must be signed in to change notification settings - Fork 1.6k
PEP 797: Arbitrary Object Immortalization #4497
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
Conversation
Python-Version: 3.15 | ||
Post-History: `01-Jul-2025 <https://discuss.python.org/t/97306>`__ | ||
|
||
Abstract |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This abstract is much longer than it should be.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok, will shorten it. Which parts do you think should be excluded/moved?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Most of it, really. The abstract should generally only be a few paragraphs. It explains primarily what the PEP does, not the motivation or implementation details.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've now significantly reduced the size of the abstract. Does that look better?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is my first time reading it, but I would say it can still be shorter -- ideally max one or two paragraphs. Perhaps:
Immortal objects have been internal to the CPython interpreter since
their introduction in :pep:`683`.
This PEP introduces a public mechanism to immortalize arbitrary objects,
while ensuring that the object is properly deallocated.
We achieve this through a pair of new functions;
:py:func:`sys._immortalize` and :c:func:`PyUnstable_Immortalize`.
These will be public and documented functions, but are expected to have
little use outside of CPython itself.
To ensure safe deallocation, we introduce a new simulated garbage collection
pass during interpreter finalisation.
I would bin the example code entirely, I don't think it significantly helps in the abstract.
Co-authored-by: Hugo van Kemenade <[email protected]>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Mainly of the first half of the PEP. The tail end of the Specification section is very prose-heavy, I've suggested moving some of the setup & exposition/context to the earlier sections.
A
@@ -0,0 +1,672 @@ | |||
PEP: 797 | |||
Title: Arbitrary Object Immortalization |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Current title reads slightly oddly to me:
Title: Arbitrary Object Immortalization | |
Title: Immortalizion of Arbitrary Objects |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hmm, I think the current title is good. How tied are you to this suggestion?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The current title reads as if object immortalisation is arbitrary, rather than that it is immortalisation of arbitrary objects: it is unclear if the correct grouping should be "arbitrary (object immortalisation)" or "(arbitrary object) immortalisation". The suggestion was an attempt to clarify, though I'd equally be fine with any other phrasing. It's not my PEP, though, so you'd be entirely within your rights to reject this idea and keep the current title.
A
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've learned from PEP 788 that I'm not good at naming PEPs, so I'm inclined to defer to you.
Python-Version: 3.15 | ||
Post-History: `01-Jul-2025 <https://discuss.python.org/t/97306>`__ | ||
|
||
Abstract |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is my first time reading it, but I would say it can still be shorter -- ideally max one or two paragraphs. Perhaps:
Immortal objects have been internal to the CPython interpreter since
their introduction in :pep:`683`.
This PEP introduces a public mechanism to immortalize arbitrary objects,
while ensuring that the object is properly deallocated.
We achieve this through a pair of new functions;
:py:func:`sys._immortalize` and :c:func:`PyUnstable_Immortalize`.
These will be public and documented functions, but are expected to have
little use outside of CPython itself.
To ensure safe deallocation, we introduce a new simulated garbage collection
pass during interpreter finalisation.
I would bin the example code entirely, I don't think it significantly helps in the abstract.
Motivation | ||
========== |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this would benefit from being split into Motivation and Rationale. Recall from PEP 12:
- Motivation: Clearly explain[s] why the existing language specification is inadequate to address the problem that the PEP solves.
- Rationale: Describe[s] why particular design decisions were made.
It's Currently Impossible to Immortalize General Objects | ||
******************************************************** |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would first argue why immortalising a general object matters or has benefits before describing the current technical restrictions that prevent doing so.
Immortalization Contract | ||
************************ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This topic & idea is introduced in Specification. Can you move the bits that already exist today to an earlier section, so that the Specification only needs to detail the changes or strengthening to the contract?
The hardest part of immortalizing arbitrary objects is dealing with | ||
deallocating them. The "intuitive" way of doing it would be to go |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This repeats the previous section, "The hardest part about immortality is the deallocation". I'd suggest that prose & the problem statement should be moved to Motivation & Rationale.
Co-authored-by: Adam Turner <[email protected]>
Ok, I think @AA-Turner is right that too much here is informational. I'm going to convert this to a PEP about shared object proxies (because that's my actual motivation here), and then do one of two things:
The former is probably the best approach unless anyone has objections. |
I think this makes sense (shared proxies & then informational on immortalisation). Do you want to reuse this PR or start anew? You can keep PEP 797 as the number regardless. A |
It'll probably be easiest to make a new PR, but I'll keep this one open until it's ready (so pepotron doesn't mistake 797 as available). |
New draft is up at #4536. I'll turn this into an informational PEP later. |
Basic requirements (all PEP Types)
pep-NNNN.rst
), PR title (PEP 123: <Title of PEP>
) andPEP
headerAuthor
orSponsor
, and formally confirmed their approvalAuthor
,Status
(Draft
),Type
andCreated
headers filled out correctlyPEP-Delegate
,Topic
,Requires
andReplaces
headers completed if appropriate.github/CODEOWNERS
for the PEPStandards Track requirements
Python-Version
set to valid (pre-beta) future Python version, if relevantDiscussions-To
andPost-History
This is following this discussion off DPO. I decided to split this into two PEPS: one for arbitrary object immortalization, and another for shared object proxies (similar to how PEP 683 and PEP 684 were split). But, I'm unsure if this was the right call. If this would all be better in one giant PEP, please let me know.
📚 Documentation preview 📚: https://pep-previews--4497.org.readthedocs.build/pep-0797/