sizeof PyTypeObject difference

Tom Widrick lordmacro at
Mon Sep 30 01:29:51 EDT 2002

I'm trying to make a metatype in C, but there seems to be some difference
between the size of the type object.

typedef struct {
 PyTypeObject type;
} MyMetaObject;

and in the tp_basicsize field I place sizeof(MyMetaObject) the value is only
196. It is the same if I put sizeof(PyTypeObject).

This causes a core dump.

>>> type.__basicsize__

If I put 444, it works fine.

What is the cause of this difference? And what is the "proper" way to do
444 + sizeof(all of my added fields of my meta type)?

More information about the Python-list mailing list