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
_PyObject_IS_GC() could be optimized in the nogil build. That function is a bit expensive since it has to check for tp_is_gc() and possibly call it. Now that all objects have ob_gc_bits, we could store the "IS GC" status as another bit there, when the object is allocated.
I think this might require a bit of refactoring, but worth doing eventually. At a glance:
_PyObject_GC_New() (and related functions) could initialize ob_gc_bits with the "IS GC" set
PyType_GenericAlloc() would also need to initialize ob_gc_bits with the "IS GC" set if the type is a GC type.
_Py_NewReference() requires some care. It. currently initializes ob_gc_bits to zero and it's used after "allocating" objects from freelists.
The text was updated successfully, but these errors were encountered:
Feature or enhancement
@nascheme writes the following suggestion (from #114564 (comment)):
I think this might require a bit of refactoring, but worth doing eventually. At a glance:
_PyObject_GC_New()
(and related functions) could initializeob_gc_bits
with the "IS GC" setPyType_GenericAlloc()
would also need to initializeob_gc_bits
with the "IS GC" set if the type is a GC type._Py_NewReference()
requires some care. It. currently initializesob_gc_bits
to zero and it's used after "allocating" objects from freelists.The text was updated successfully, but these errors were encountered: