From c916f5a390b0ca559de54a15d4014e18792674ea Mon Sep 17 00:00:00 2001 From: Fred Drake Date: Fri, 26 Oct 2001 17:56:51 +0000 Subject: Be smarter about clearing the weakref lists for instances, instance methods, and functions: we only need to call PyObject_ClearWeakRefs() if the weakref list is non-NULL. Since these objects are common but weakrefs are still unusual, saving the call at deallocation time makes a lot of sense. --- Objects/funcobject.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'Objects/funcobject.c') diff --git a/Objects/funcobject.c b/Objects/funcobject.c index 89dd7f9d91..d978c3f07e 100644 --- a/Objects/funcobject.c +++ b/Objects/funcobject.c @@ -270,7 +270,8 @@ static void func_dealloc(PyFunctionObject *op) { _PyObject_GC_UNTRACK(op); - PyObject_ClearWeakRefs((PyObject *) op); + if (op->func_weakreflist != NULL) + PyObject_ClearWeakRefs((PyObject *) op); Py_DECREF(op->func_code); Py_DECREF(op->func_globals); Py_DECREF(op->func_name); -- cgit v1.2.1