mirror of
https://github.com/python/cpython.git
synced 2025-08-01 23:53:15 +00:00
gh-117376: Partial implementation of deferred reference counting (#117696)
This marks objects as using deferred refrence counting using the `ob_gc_bits` field in the free-threaded build and collects those objects during GC.
This commit is contained in:
parent
c50cb6dd09
commit
4ad8f090cc
9 changed files with 82 additions and 21 deletions
|
@ -158,6 +158,21 @@ static inline void _Py_ClearImmortal(PyObject *op)
|
|||
op = NULL; \
|
||||
} while (0)
|
||||
|
||||
// Mark an object as supporting deferred reference counting. This is a no-op
|
||||
// in the default (with GIL) build. Objects that use deferred reference
|
||||
// counting should be tracked by the GC so that they are eventually collected.
|
||||
extern void _PyObject_SetDeferredRefcount(PyObject *op);
|
||||
|
||||
static inline int
|
||||
_PyObject_HasDeferredRefcount(PyObject *op)
|
||||
{
|
||||
#ifdef Py_GIL_DISABLED
|
||||
return (op->ob_gc_bits & _PyGC_BITS_DEFERRED) != 0;
|
||||
#else
|
||||
return 0;
|
||||
#endif
|
||||
}
|
||||
|
||||
#if !defined(Py_GIL_DISABLED)
|
||||
static inline void
|
||||
_Py_DECREF_SPECIALIZED(PyObject *op, const destructor destruct)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue