Explain that tp_basicsize must provide alignment for the items.
authorGuido van Rossum <guido@python.org>
Fri, 31 May 2002 21:00:18 +0000 (21:00 +0000)
committerGuido van Rossum <guido@python.org>
Fri, 31 May 2002 21:00:18 +0000 (21:00 +0000)
Doc/api/newtypes.tex

index 8d862dbd650f206c8ecbcfb9dbd2daec0873980c..69c49f29a144ea50146911739079500518946ae3 100644 (file)
@@ -465,6 +465,14 @@ Foo_Type.ob_type = &PyType_Type;
   has a non-zero \member{tp_itemsize}, it is generally not safe to set
   \member{tp_itemsize} to a different non-zero value in a subtype
   (though this depends on the implementation of the base type).
+
+  A note about alignment: if the variable items require a particular
+  alignment, this should be taken care of by the value of
+  \member{tp_basicsize}.  Example: suppose a type implements an array
+  of \code{double}. \member{tp_itemsize} is \code{sizeof(double)}.
+  It is the programmer's responsibility that \member{tp_basicsize} is
+  a multiple of \code{sizeof(double)} (assuming this is the alignment
+  requirement for \code{double}).
 \end{cmemberdesc}
 
 \begin{cmemberdesc}{PyTypeObject}{destructor}{tp_dealloc}