Description
Bug report
Bug description:
Immortal objects should live forever. By definition, immortality is a permanent property of an object; if it can loose immortality, then it wasn't immortal in the first place.
Immortality allows some useful optimizations and safety guarantees that can make CPython faster and more robust.
Which would be great, if we didn't play fast and loose with immortality.
For no good reason that I'm aware of there are two functions _Py_ClearImmortal
and _Py_SetMortal
that make immortal objects mortal. This is nonsense. We must remove these functions.
We have also added _Py_IsImmortalLoose
because it is too easy for C-extensions
Instead of adding these workarounds, we need to fix this problem as well.
Let's fix immortality so that we can rely on it and take advantage of it.
CPython versions tested on:
3.12, 3.13, CPython main branch
Operating systems tested on:
Other
Linked PRs
- GH-125174: Make immortal objects more robust, following design from PEP 683 #125251
- GH-125174: Mark objects as statically allocated. #127797
- GH-125174: Fix compiler warning #127860
- GH-125174: Don't use
UINT32_MAX
in header file #127863 - GH-125174: Make immortality "sticky" #131184
- GH-125174 Revert: Make immortality "sticky" (GH-131184)" #131230
- GH-125174: Make immortality "sticky" #131355