[Python-3000] PyObject_HEAD_INIT
M.-A. Lemburg
mal at egenix.com
Thu Nov 20 13:39:50 CET 2008
On 2008-11-14 22:15, Roger Binns wrote:
> My confusion was because I though that the HEAD for the data structure
> had to use the same corresponding HEAD_INIT in the type. So for
> whatever reason the PyTypeObject is declared as a var object which is
> why the var HEAD_INIT is needed.
>
> It still looks like PyObject_HEAD_INIT should be removed so that people
> using earlier versions of Python, following the Py3 docs (before they
> are fixed), using older tutorials etc don't get burnt.
>
> Grepping through the py3 source shows only PyModuleDef_HEAD_INIT using
> PyObject_HEAD_INIT. There are no other legitimate uses!
Except maybe a few thousand extensions already using it which are
waiting to be ported to Python 3.
Whether you write:
{PyObject_HEAD_INIT(0), 0, ...
or
{PyVarObject_HEAD_INIT(0, 0), ...
for your type definition doesn't really make much difference. They
both unwrap to the same code. Since PyTypeObjects are variable length
objects, you always need the ob_size entry.
However, the macros exist to be used for both variable size
and fixed size objects, so having both available is useful and
legitimate.
--
Marc-Andre Lemburg
eGenix.com
Professional Python Services directly from the Source (#1, Nov 20 2008)
>>> Python/Zope Consulting and Support ... http://www.egenix.com/
>>> mxODBC.Zope.Database.Adapter ... http://zope.egenix.com/
>>> mxODBC, mxDateTime, mxTextTools ... http://python.egenix.com/
________________________________________________________________________
2008-11-12: Released mxODBC.Connect 0.9.3 http://python.egenix.com/
:::: Try mxODBC.Zope.DA for Windows,Linux,Solaris,MacOSX for free ! ::::
eGenix.com Software, Skills and Services GmbH Pastor-Loeh-Str.48
D-40764 Langenfeld, Germany. CEO Dipl.-Math. Marc-Andre Lemburg
Registered at Amtsgericht Duesseldorf: HRB 46611
More information about the Python-3000
mailing list