Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 9788384

Browse files
committed
Explain that tp_basicsize must provide alignment for the items.
1 parent ebb4190 commit 9788384

1 file changed

Lines changed: 8 additions & 0 deletions

File tree

Doc/api/newtypes.tex

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -465,6 +465,14 @@ \section{Type Objects \label{type-structs}}
465465
has a non-zero \member{tp_itemsize}, it is generally not safe to set
466466
\member{tp_itemsize} to a different non-zero value in a subtype
467467
(though this depends on the implementation of the base type).
468+
469+
A note about alignment: if the variable items require a particular
470+
alignment, this should be taken care of by the value of
471+
\member{tp_basicsize}. Example: suppose a type implements an array
472+
of \code{double}. \member{tp_itemsize} is \code{sizeof(double)}.
473+
It is the programmer's responsibility that \member{tp_basicsize} is
474+
a multiple of \code{sizeof(double)} (assuming this is the alignment
475+
requirement for \code{double}).
468476
\end{cmemberdesc}
469477

470478
\begin{cmemberdesc}{PyTypeObject}{destructor}{tp_dealloc}

0 commit comments

Comments
 (0)