Explain that tp_basicsize must provide alignment for the items.

This commit is contained in:
Guido van Rossum 2002-05-31 21:00:18 +00:00
parent ebb4190709
commit 9788384d02
1 changed files with 8 additions and 0 deletions

View 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}