[Python-checkins] r55295 - peps/trunk/pep-3123.txt

martin.v.loewis python-checkins at python.org
Sun May 13 16:23:07 CEST 2007


Author: martin.v.loewis
Date: Sun May 13 16:23:03 2007
New Revision: 55295

Modified:
   peps/trunk/pep-3123.txt
Log:
Include implementation experience.


Modified: peps/trunk/pep-3123.txt
==============================================================================
--- peps/trunk/pep-3123.txt	(original)
+++ peps/trunk/pep-3123.txt	Sun May 13 16:23:03 2007
@@ -106,11 +106,13 @@
 accesses to ob_refcnt and ob_type MUST cast the object pointer to
 PyObject* (unless the pointer is already known to have that type), and
 SHOULD use the respective accessor macros. To simplify access to
-ob_type, a macro::
+ob_type, ob_refcnt, and ob_size, macros::
 
-  #define Py_Type(o) (((PyObject*)o)->ob_type)
+  #define Py_Type(o)    (((PyObject*)(o))->ob_type)
+  #define Py_Refcnt(o)  (((PyObject*)(o))->ob_refcnt)
+  #define Py_Size(o)    (((PyVarObject*)(o))->ob_size)
 
-is added. E.g. the code blocks::
+are added. E.g. the code blocks::
 
   #define PyList_CheckExact(op) ((op)->ob_type == &PyList_Type)
 
@@ -121,13 +123,21 @@
   #define PyList_CheckExact(op) (Py_Type(op) == &PyList_Type)
 
   return Py_Type(func)->tp_name;
-  
+
+For initialization of type objects, the current sequence::
+
+  PyObject_HEAD_INIT(NULL)
+  0, /* ob_size */
+
+becomes incorrect, and must be replaced with
+
+  PyVarObject_HEAD_INIT(NULL, 0)
 
 Compatibility with Python 2.6
 =============================
 
 To support modules that compile with both Python 2.6 and Python 3.0,
-the Py_Type macro is added to Python 2.6. The macros Py_INCREF
+the Py_* macros is added to Python 2.6. The macros Py_INCREF
 and Py_DECREF will be changed to cast their argument to PyObject\*,
 so that module authors can also explicitly declare the ob_base
 field in modules designed for Python 2.6. 


More information about the Python-checkins mailing list