[Python-checkins] CVS: python/dist/src/Objects classobject.c,2.153,2.154 funcobject.c,2.46,2.47
Fred L. Drake
fdrake@users.sourceforge.net
Fri, 26 Oct 2001 10:56:53 -0700
Update of /cvsroot/python/python/dist/src/Objects
In directory usw-pr-cvs1:/tmp/cvs-serv12022
Modified Files:
classobject.c funcobject.c
Log Message:
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.
Index: classobject.c
===================================================================
RCS file: /cvsroot/python/python/dist/src/Objects/classobject.c,v
retrieving revision 2.153
retrieving revision 2.154
diff -C2 -d -r2.153 -r2.154
*** classobject.c 2001/10/22 02:00:09 2.153
--- classobject.c 2001/10/26 17:56:51 2.154
***************
*** 586,590 ****
#endif
_PyObject_GC_UNTRACK(inst);
! PyObject_ClearWeakRefs((PyObject *) inst);
/* Temporarily resurrect the object. */
--- 586,591 ----
#endif
_PyObject_GC_UNTRACK(inst);
! if (inst->in_weakreflist != NULL)
! PyObject_ClearWeakRefs((PyObject *) inst);
/* Temporarily resurrect the object. */
***************
*** 2072,2076 ****
{
_PyObject_GC_UNTRACK(im);
! PyObject_ClearWeakRefs((PyObject *)im);
Py_DECREF(im->im_func);
Py_XDECREF(im->im_self);
--- 2073,2078 ----
{
_PyObject_GC_UNTRACK(im);
! if (im->im_weakreflist != NULL)
! PyObject_ClearWeakRefs((PyObject *)im);
Py_DECREF(im->im_func);
Py_XDECREF(im->im_self);
Index: funcobject.c
===================================================================
RCS file: /cvsroot/python/python/dist/src/Objects/funcobject.c,v
retrieving revision 2.46
retrieving revision 2.47
diff -C2 -d -r2.46 -r2.47
*** funcobject.c 2001/10/05 20:51:38 2.46
--- funcobject.c 2001/10/26 17:56:51 2.47
***************
*** 271,275 ****
{
_PyObject_GC_UNTRACK(op);
! PyObject_ClearWeakRefs((PyObject *) op);
Py_DECREF(op->func_code);
Py_DECREF(op->func_globals);
--- 271,276 ----
{
_PyObject_GC_UNTRACK(op);
! if (op->func_weakreflist != NULL)
! PyObject_ClearWeakRefs((PyObject *) op);
Py_DECREF(op->func_code);
Py_DECREF(op->func_globals);