You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Avoid boilerplate for traversing a mutable heap type #138342
Throughout the codebase, instances of mutable heap types must always implement the GC protocol to traverse their type. This leads to the following being repeated a lot:
When this boilerplate was added at first place, I suggested to do this automatically for each heap type with the Py_TPFLAGS_HAVE_GC flag. It belongs to the garbage collector (which does type-specific things in any case), no need to pollute the source code with Py_VISIT(Py_TYPE(op)). For some reasons my suggestion was ignored.
Exactly. Now, after adding all these Py_VISIT(Py_TYPE(op)), we cannot use that approach and are doomed to add Py_VISIT(Py_TYPE(op)) in each tp_traverse.
Activity
serhiy-storchaka commentedon Sep 1, 2025
When this boilerplate was added at first place, I suggested to do this automatically for each heap type with the Py_TPFLAGS_HAVE_GC flag. It belongs to the garbage collector (which does type-specific things in any case), no need to pollute the source code with
Py_VISIT(Py_TYPE(op)). For some reasons my suggestion was ignored.picnixz commentedon Sep 1, 2025
I think you were talking about #84398 right?
serhiy-storchaka commentedon Sep 1, 2025
Exactly. Now, after adding all these
Py_VISIT(Py_TYPE(op)), we cannot use that approach and are doomed to addPy_VISIT(Py_TYPE(op))in eachtp_traverse.gh-138342: Use a common utility for visiting an object's type (GH-138343
pythongh-138342: Use a common utility for visiting an object's type (p…
pythongh-138342: Move _PyObject_VisitType() to the internal C API
gh-138342: Move _PyObject_VisitType() to the internal C API (#139734)