From 675d9a3d7afc767a2818c84da7ba4bf4181dcf26 Mon Sep 17 00:00:00 2001 From: Hai Shi Date: Wed, 15 Apr 2020 02:11:20 +0800 Subject: bpo-40170: Convert PyObject_IS_GC() macro to a function (GH-19464) --- Include/internal/pycore_object.h | 9 +++++++++ 1 file changed, 9 insertions(+) (limited to 'Include/internal/pycore_object.h') diff --git a/Include/internal/pycore_object.h b/Include/internal/pycore_object.h index 7c0f24ac07..32e86d06db 100644 --- a/Include/internal/pycore_object.h +++ b/Include/internal/pycore_object.h @@ -102,6 +102,15 @@ _PyType_HasFeature(PyTypeObject *type, unsigned long feature) { return ((type->tp_flags & feature) != 0); } +// Fast inlined version of PyObject_IS_GC() +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))); +} + // Fast inlined version of PyType_IS_GC() #define _PyType_IS_GC(t) _PyType_HasFeature((t), Py_TPFLAGS_HAVE_GC) -- cgit v1.2.1