[Python-3000] PyObject_HEAD_INIT
Roger Binns
rogerb at rogerbinns.com
Thu Nov 20 20:34:18 CET 2008
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
M.-A. Lemburg wrote:
> Whether you write:
>
> {PyObject_HEAD_INIT(0), 0, ...
>
> or
>
> {PyVarObject_HEAD_INIT(0, 0), ...
>
> for your type definition doesn't really make much difference.
Actually in Py 3 it does. If you use the former (which is how Py 2 does
it) then you get serious compiler warnings due to misaligned fields in
Py 3 and presumably even worse if run the code. See PEP 3123 as to why
things changed. That is why all the code in Python 3 was changed from
using the former to the latter.
> However, the macros exist to be used for both variable size
> and fixed size objects, so having both available is useful and
> legitimate.
...
> Except maybe a few thousand extensions already using it which are
> waiting to be ported to Python 3.
Can you point to any? All the ones I found (via Google) only use
PyObject_HEAD_INIT for PyTypeObjects and every single one of those will
have to change to using PyVarObject_HEAD_INIT.
Roger
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.9 (GNU/Linux)
iEYEARECAAYFAkklu7UACgkQmOOfHg372QTZBQCgt3kwtUYF3Us8hjPAS2PvDtpm
l+EAoJUata+K55mboNB0UpMsLlzoRpnA
=WbrQ
-----END PGP SIGNATURE-----
More information about the Python-3000
mailing list