diff Objects/funcobject.c @ 20698:b229208a2a72 legacy-trunk

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.
author Fred Drake <fdrake@acm.org>
date Fri, 26 Oct 2001 17:56:51 +0000
parents 2983b54256c7
children fd42eace50ea
line wrap: on
line diff
--- a/Objects/funcobject.c	Fri Oct 26 17:40:22 2001 +0000
+++ b/Objects/funcobject.c	Fri Oct 26 17:56:51 2001 +0000
@@ -270,7 +270,8 @@
 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);