Half-baked idea (was Re: [Python-Dev] Extending types in C - help needed)

Guido van Rossum guido@python.org
Fri, 08 Feb 2002 14:51:02 -0500

[Idea about extending variable-length structures at the front instead
of at the back]

The problem with applying this idea to Python objects, IMO, is that
Python requires the object header to be at the start.  Anything
operating on a PyObject * expects that it can use the Py_INCREF and
Py_DECREF macros, and those expect the refcount to be the first field
and the type pointer to be the second.

So our objects are already constrained at the front.

Also, the GC implementation already uses thistrick: it adds three
fields in front of the structure.  But then it assumes you can use
fixed address calculations to translate between the object and the GC
header.  Adding something in front of the GC header would be too

--Guido van Rossum (home page: http://www.python.org/~guido/)