Uh oh!
There was an error while loading. Please reload this page.
gh-139716: Make PyStackRef_FromPyObjectSteal function very lightweight for GIL build as on FT build - #143024
Conversation
efimov-mikhail
commented
Dec 20, 2025
efimov-mikhail
commented
Dec 20, 2025
If this PR will be merged we can remove |
Fidget-Spinner
commented
Dec 20, 2025
We can't rely on Py_DECREF to do the immortal check, as that is more expensive than simply checking a bit on a pointer. You have to do an atomic read of memory now. |
It seems that I'm not quite understand, when we will do additional atomic reads. |
Fidget-Spinner
commented
Dec 20, 2025
Sorry I think I'm misunderstanding. This PR moves the immortal check from the stackref to the Py_DECREF right? |
efimov-mikhail
commented
Dec 20, 2025
Yes. If we steal stack reference from the immortal object then there will be no actual decrefing at |
kumaraditya303
commented
Dec 21, 2025
Actually for immortal check, only |
colesbury
commented
Dec 22, 2025
|
markshannon
commented
Jan 8, 2026
I like the idea of merging the two implementations, but why choose the slower scheme, not the faster one? |
This PR is stale because it has been open for 30 days with no activity. |
This is another attempt to provide the same StackRef flagging scheme for all builds (GIL, FT, STACKREF_DEBUG).
Instead of adding
_Py_IsImmortalcheck toPyStackRef_FromPyObjectStealfor FT builds as in #141675, we make no checks at all in this function.As a result, immortal objects will be DECREF'ed with no effect at reference closing.
PyStackReffunctions #139716