[Python-checkins] python/dist/src/Include object.h,2.110,2.111

gvanrossum@users.sourceforge.net gvanrossum@users.sourceforge.net
Thu, 08 Aug 2002 13:55:22 -0700


Update of /cvsroot/python/python/dist/src/Include
In directory usw-pr-cvs1:/tmp/cvs-serv17558/Include

Modified Files:
	object.h 
Log Message:
A modest speedup of object deallocation.  call_finalizer() did rather
a lot of work: it had to save and restore the current exception around
a call to lookup_maybe(), because that could fail in rare cases, and
most objects don't have a __del__ method, so the whole exercise was
usually a waste of time.  Changed this to cache the __del__ method in
the type object just like all other special methods, in a new slot
tp_del.  So now subtype_dealloc() can test whether tp_del is NULL and
skip the whole exercise if it is.  The new slot doesn't need a new
flag bit: subtype_dealloc() is only called if the type was dynamically
allocated by type_new(), so it's guaranteed to have all current slots.
Types defined in C cannot fill in tp_del with a function of their own,
so there's no corresponding "wrapper".  (That functionality is already
available through tp_dealloc.)



Index: object.h
===================================================================
RCS file: /cvsroot/python/python/dist/src/Include/object.h,v
retrieving revision 2.110
retrieving revision 2.111
diff -C2 -d -r2.110 -r2.111
*** object.h	7 Aug 2002 20:53:05 -0000	2.110
--- object.h	8 Aug 2002 20:55:20 -0000	2.111
***************
*** 316,319 ****
--- 316,320 ----
  	PyObject *tp_subclasses;
  	PyObject *tp_weaklist;
+ 	destructor tp_del;
  
  #ifdef COUNT_ALLOCS