[Python-checkins] CVS: python/dist/src/Include object.h,2.94,2.95

Guido van Rossum gvanrossum@users.sourceforge.net
Mon, 08 Oct 2001 08:18:29 -0700


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

Modified Files:
	object.h 
Log Message:
Keep track of a type's subclasses (subtypes), in tp_subclasses, which
is a list of weak references to types (new-style classes).  Make this
accessible to Python as the function __subclasses__ which returns a
list of types -- we don't want Python programmers to be able to
manipulate the raw list.

In order to make this possible, I also had to add weak reference
support to type objects.

This will eventually be used together with a trap on attribute
assignment for dynamic classes for a major speed-up without losing the
dynamic properties of types: when a __foo__ method is added to a
class, the class and all its subclasses will get an appropriate tp_foo
slot function.



Index: object.h
===================================================================
RCS file: /cvsroot/python/python/dist/src/Include/object.h,v
retrieving revision 2.94
retrieving revision 2.95
diff -C2 -d -r2.94 -r2.95
*** object.h	2001/10/05 21:58:11	2.94
--- object.h	2001/10/08 15:18:27	2.95
***************
*** 290,293 ****
--- 290,295 ----
  	PyObject *tp_mro; /* method resolution order */
  	PyObject *tp_defined;
+ 	PyObject *tp_subclasses;
+ 	PyObject *tp_weaklist;
  
  #ifdef COUNT_ALLOCS