Skip to content

gh-158401: Add a function to refresh an immortal object's refcount - #162224

Draft
encukou wants to merge 1 commit into
python:mainfrom
encukou:deimmortalization
Draft

encukou wants to merge 1 commit into
python:mainfrom
encukou:deimmortalization

Conversation

@encukou

@encukou encukou commented Nov 18, 2026 •

Copy link
Copy Markdown
Member

Here's another way to help with de-immortalization: reset the refcount periodically, in GIL builds.
This isn't a complete fix as I don't think we can do it reliably. GC doesn't/shouldn't really touch immortal objects, and doing this too often
For an example, or first approximation, we can do it for extension function results (through which None/True/False are likely to go, and which are sufficiently heavy-weight operations so the assignment cost is ~noise), but there are probably other places where this would be useful.

This patch also calls it for extension function results, which are
likely to be the commonly affected True/None/False.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

needs backport to 3.14 bugs and security fixes needs backport to 3.15 bugs and security fixes

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant