[Python-checkins] CVS: python/dist/src/Include objimpl.h,2.33,2.34

Fred L. Drake fdrake@users.sourceforge.net
Thu, 22 Mar 2001 10:26:49 -0800


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

Modified Files:
	objimpl.h 
Log Message:

A small change to the C API for weakly-referencable types:  Such types
must now initialize the extra field used by the weak-ref machinery to
NULL themselves, to avoid having to require PyObject_INIT() to check
if the type supports weak references and do it there.  This causes less
work to be done for all objects (the type object does not need to be
consulted to check for the Py_TPFLAGS_HAVE_WEAKREFS bit).


Index: objimpl.h
===================================================================
RCS file: /cvsroot/python/python/dist/src/Include/objimpl.h,v
retrieving revision 2.33
retrieving revision 2.34
diff -C2 -r2.33 -r2.34
*** objimpl.h	2001/02/27 04:45:05	2.33
--- objimpl.h	2001/03/22 18:26:47	2.34
***************
*** 168,176 ****
     Note that these macros expect non-NULL object pointers.*/
  #define PyObject_INIT(op, typeobj) \
! 	((op)->ob_type = (typeobj), _Py_NewReference((PyObject *)(op)), \
! 	 (PyType_SUPPORTS_WEAKREFS((typeobj)) \
! 	      ? *(PyObject_GET_WEAKREFS_LISTPTR(op)) = NULL \
!               : NULL), \
!          (op))
  #define PyObject_INIT_VAR(op, typeobj, size) \
  	( (op)->ob_size = (size), PyObject_INIT((op), (typeobj)) )
--- 168,172 ----
     Note that these macros expect non-NULL object pointers.*/
  #define PyObject_INIT(op, typeobj) \
! 	( (op)->ob_type = (typeobj), _Py_NewReference((PyObject *)(op)), (op) )
  #define PyObject_INIT_VAR(op, typeobj, size) \
  	( (op)->ob_size = (size), PyObject_INIT((op), (typeobj)) )