mirror of
https://github.com/python/cpython.git
synced 2025-11-01 18:51:43 +00:00
gh-105268: Add _Py_FROM_GC() function to pycore_gc.h (#105362)
* gcmodule.c reuses _Py_AS_GC(op) for AS_GC() * Move gcmodule.c FROM_GC() implementation to a new _Py_FROM_GC() static inline function in pycore_gc.h. * _PyObject_IS_GC(): only get the type once * gc_is_finalized(à) and PyObject_GC_IsFinalized() use _PyGC_FINALIZED(), instead of _PyGCHead_FINALIZED(). * Remove _Py_CAST() in pycore_gc.h: this header file is not built with C++.
This commit is contained in:
parent
963099ebd9
commit
c7bf74bacd
3 changed files with 27 additions and 18 deletions
|
|
@ -326,9 +326,9 @@ _PyObject_GET_WEAKREFS_LISTPTR_FROM_OFFSET(PyObject *op)
|
|||
static inline int
|
||||
_PyObject_IS_GC(PyObject *obj)
|
||||
{
|
||||
return (PyType_IS_GC(Py_TYPE(obj))
|
||||
&& (Py_TYPE(obj)->tp_is_gc == NULL
|
||||
|| Py_TYPE(obj)->tp_is_gc(obj)));
|
||||
PyTypeObject *type = Py_TYPE(obj);
|
||||
return (PyType_IS_GC(type)
|
||||
&& (type->tp_is_gc == NULL || type->tp_is_gc(obj)));
|
||||
}
|
||||
|
||||
// Fast inlined version of PyType_IS_GC()
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue