Skip to content

gh-159437: Count garbage during weakref cleanup - #159598

Draft
mfalco-oai wants to merge 3 commits into
python:mainfrom
mfalco-oai:mfalco-oai/gh-159437-gc-count
Draft

mfalco-oai wants to merge 3 commits into
python:mainfrom
mfalco-oai:mfalco-oai/gh-159437-gc-count

Conversation

@mfalco-oai

@mfalco-oai mfalco-oai commented Oct 16, 2026 •

Copy link
Copy Markdown

With this optimization the GIL collector counts collectable objects during late weakref cleanup. This removes the separate gc_list_size() walk over the same list.

@pablogsal pablogsal left a comment •

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The counting change seems independent of the callback refactor. clear_weakrefs() already walks the final collectable list without running Python, so returning its size doesn't need the new callback helper or list selection. Let's keep this change seperate if that refactor gets reworked.

@mfalco-oai
mfalco-oai force-pushed the mfalco-oai/gh-159437-gc-count branch from 768f2d6 to 934dc3b Compare October 19, 2026 22:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

type-feature A feature request or enhancement

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants