Skip to content

Conversation

@brandtbucher
Copy link
Member

@brandtbucher brandtbucher commented Nov 18, 2025

This adds a useful "duration" stat to gc.get_stats and gc.callbacks. It also fixes an issue where the existing timer could be used uninitialized if the GC's debug flags are set during a collection.


📚 Documentation preview 📚: https://cpython-previews--141720.org.readthedocs.build/

@brandtbucher brandtbucher self-assigned this Nov 18, 2025
@brandtbucher brandtbucher added type-feature A feature request or enhancement interpreter-core (Objects, Python, Grammar, and Parser dirs) labels Nov 18, 2025
* ``uncollectable`` is the total number of objects which were found
to be uncollectable (and were therefore moved to the :data:`garbage`
list) inside this generation.
list) inside this generation;
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
list) inside this generation;
list) inside this generation.

Copy link
Member Author

Choose a reason for hiding this comment

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

I just did this for consistency with the above points, haha.

assert(PyList_CheckExact(gcstate->callbacks));
PyObject *info = NULL;
if (PyList_GET_SIZE(gcstate->callbacks) != 0) {
info = Py_BuildValue("{sisnsn}",
Copy link
Member

Choose a reason for hiding this comment

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

You need to change this line to

Suggested change
info = Py_BuildValue("{sisnsn}",
info = Py_BuildValue("{sisnsnsd}",

no?

Copy link
Member Author

Choose a reason for hiding this comment

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

Nice catch, thanks. Annoying that it just ignores trailing args like that.

Copy link
Member

@pablogsal pablogsal left a comment

Choose a reason for hiding this comment

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

LGTM I left some comments

@IsmaNegey

This comment was marked as spam.

@brandtbucher brandtbucher merged commit 598d4c6 into python:main Nov 19, 2025
46 checks passed
StanFromIreland pushed a commit to StanFromIreland/cpython that referenced this pull request Dec 6, 2025
ashm-dev pushed a commit to ashm-dev/cpython that referenced this pull request Dec 8, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

interpreter-core (Objects, Python, Grammar, and Parser dirs) type-feature A feature request or enhancement

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants