sizeof PyTypeObject difference

Tom Widrick lordmacro at hotmail.com
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.
However,

>>> type.__basicsize__
444

If I put 444, it works fine.

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







More information about the Python-list mailing list