-
-
Notifications
You must be signed in to change notification settings - Fork 33.7k
gh-139716: Make PyStackRef_FromPyObjectSteal function very lightweight for GIL build as on FT build
#143024
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
base: main
Are you sure you want to change the base?
gh-139716: Make PyStackRef_FromPyObjectSteal function very lightweight for GIL build as on FT build
#143024
Conversation
|
If this PR will be merged we can remove |
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. |
|
Sorry I think I'm misunderstanding. This PR moves the immortal check from the stackref to the Py_DECREF right? |
Yes. If we steal stack reference from the immortal object then there will be no actual decrefing at |
Actually for immortal check, only |
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