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
PEP 683: Small Updates #2622
base: main
Are you sure you want to change the base?
PEP 683: Small Updates #2622
Conversation
|
@eduardo-elizondo, does this look okay? |
| Consequently, such an object's refcount will never reach 0, and thus the | ||
| object will never be cleaned up. We call these objects "immortal". |
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'd like to add here that while these objects will never be cleaned up during the runtime, except, when the runtime knows it's safe to do safe. For example, at runtime shutdown when we clean and deallocate all strings.
Option 1:
and thus the object will never be cleaned up, unless explicitly deallocated by the runtime.
Option 2:
and thus the object will never be cleaned up, unless explicitly deallocated by the runtime when it knows it's safe to do so.
What do you think?
| @@ -204,7 +204,7 @@ Performance | |||
|
|
|||
| A naive implementation shows `a 4% slowdown`_. We have demonstrated | |||
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.
Not sure if the specific number matters too much but this 4% was measured in a pretty old branch. When I remeasured this with a branch from April 2022 for PyCon, it was at ~6% for the naive implementation.
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 noticed on reddit, btw, that some people who read my Language Summit article were also slightly confused about whether immortal objects would make things faster or slower :) https://www.reddit.com/r/Python/comments/unx80h/comment/i8c2q7p/
| @@ -321,8 +322,8 @@ Even then the overall impact is unlikely to be significant. | |||
| Accidental De-Immortalizing | |||
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 UI doesn't let me add a comment where I want it but in the paragraph above, it says:
However, we do ensure that immortal objects (mostly) stay immortal
in that situation. We set the initial refcount of immortal objects to
a value high above the magic refcount value, but one that still matches
the high bit.
This might be too specific on the implementation details (i.e assuming it's using a high bit). Under the new lower 32 bit strategy (which we use for better perf) these assumptions might change.
Maybe let's just drop the last sense that says: "but one that still matches the high bit"?
| (but not int, due to frequency?) | ||
| * provide a runtime flag for disabling immortality | ||
| We look at possible solutions | ||
| `later on <Solutions for Accidental De-Immortalization>`_. | ||
|
|
||
| Alternate Python Implementations | ||
| -------------------------------- |
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.
In the Maintainability section below, it says:
However, that should be limited to where we immortalize all
objects post-init and that code will be in one place.
What about extending that to say:
However, that should be limited to where we immortalize all
objects post-init and explicitly deallocate them at runtime shutdown.
As I've investigated in some of the mitigation strategy, it might be hard to guarantee that the code that immortalizes all objects will be in one single place. For instance, interned strings are immortalized when they are created inside the unicode C-API functions.
Also, wanted explicitly call out that these are deallocating immortal objects at shutdown
| @@ -416,9 +412,9 @@ makes it immortal. | |||
|
|
|||
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.
In the specification above, the second bullet point, maybe let's remove the part that says: '(or its most significant bit)', I think the sentence before that is specific enough and this parenthesis dives into implementation details
| * (Larry,MAL) mark all constants unmarshalled for a module as immortal | ||
| * (Larry,MAL) allocate (immutable) immortal objects in their own memory page(s) | ||
|
|
||
| Solutions for Accidental De-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.
Looks solid! Thanks for expanding this!
Thanks for the updates, looks solid!
I also added some other comments on areas that not specific to this PR but relevant to the whole PEP.


This covers typos, tweaks in wording, and some adjustments in response to the last email thread.
@eduardo-elizondo will be making an update with additional technical details before we post the PEP for another round of discussion.