[Python-checkins] CVS: python/dist/src/Objects typeobject.c,2.16.8.52,2.16.8.53
Guido van Rossum
gvanrossum@users.sourceforge.net
Fri, 29 Jun 2001 13:03:16 -0700
Update of /cvsroot/python/python/dist/src/Objects
In directory usw-pr-cvs1:/tmp/cvs-serv926
Modified Files:
Tag: descr-branch
typeobject.c
Log Message:
Aargh!
During an innocent benchmark test I found out that a simple getattr
operation on an instance of a static type was 20x slower than one on
an instance of a dynamic type. It took an hour of tracing in the
debugger to realize that the call override_slots(type, type->tp_dict)
at the end of type_init() was wrong, and should really be
override_slots(type, type->tp_defined). The tp_getattro slot had
turned into a wrapper for __getattr__, which in turn was a wrapper
around the base class's tp_getattro slot.
(The solution isn't quite right, because slots are now inherited from
the "strongest base" only, while they should be inherited from all
bases; but that's a separate issue; it's no worse than before, and the
speed glitch is gone.)
Index: typeobject.c
===================================================================
RCS file: /cvsroot/python/python/dist/src/Objects/typeobject.c,v
retrieving revision 2.16.8.52
retrieving revision 2.16.8.53
diff -C2 -r2.16.8.52 -r2.16.8.53
*** typeobject.c 2001/06/29 16:00:54 2.16.8.52
--- typeobject.c 2001/06/29 20:03:14 2.16.8.53
***************
*** 577,581 ****
/* Override slots that deserve it */
! override_slots(type, type->tp_dict);
return (PyObject *)type;
}
--- 577,581 ----
/* Override slots that deserve it */
! override_slots(type, type->tp_defined);
return (PyObject *)type;
}