Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

gh-139716: MakePyStackRef_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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Open
efimov-mikhail wants to merge2 commits intopython:main
base:main
Choose a base branch
Loading
fromefimov-mikhail:issue-139716-stackref-immortal-gil-2

Conversation

@efimov-mikhail
Copy link
Member

@efimov-mikhailefimov-mikhail commentedDec 20, 2025
edited
Loading

This is another attempt to provide the same StackRef flagging scheme for all builds (GIL, FT, STACKREF_DEBUG).
Instead of adding_Py_IsImmortal check toPyStackRef_FromPyObjectSteal for 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.

@efimov-mikhail
Copy link
MemberAuthor

@efimov-mikhail
Copy link
MemberAuthor

If this PR will be merged we can removePyStackRef_FromPyObjectStealMortal at all.
OTOH, I'd like to provide this change in a separate PR.

@Fidget-Spinner
Copy link
Member

This is another attempt to provide the same StackRef flagging scheme for all builds (GIL, FT, STACKREF_DEBUG). Instead of adding_Py_IsImmortal check toPyStackRef_FromPyObjectSteal for FR 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.

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.

efimov-mikhail reacted with eyes emoji

@efimov-mikhail
Copy link
MemberAuthor

efimov-mikhail commentedDec 20, 2025
edited
Loading

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.
Do you mean FT builds? For those nothing changes sincePy_DECREF_MORTAL isPy_DECREF on them.
And there's no atomic reads atPy_DECREF on GIL builds.

@Fidget-Spinner
Copy link
Member

Sorry I think I'm misunderstanding. This PR moves the immortal check from the stackref to the Py_DECREF right?

@efimov-mikhail
Copy link
MemberAuthor

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 atPy_DECREF.

Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment

Reviewers

@Fidget-SpinnerFidget-SpinnerAwaiting requested review from Fidget-SpinnerFidget-Spinner is a code owner

@AA-TurnerAA-TurnerAwaiting requested review from AA-TurnerAA-Turner is a code owner

Assignees

No one assigned

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

2 participants

@efimov-mikhail@Fidget-Spinner

[8]ページ先頭

©2009-2025 Movatter.jp