[Python-Dev] cpython: Using 'long double' to force this structure to be worst case aligned is no

Antoine Pitrou solipsis at pitrou.net
Fri Dec 14 10:41:41 CET 2012

Le Fri, 14 Dec 2012 01:14:04 -0800,
"Gregory P. Smith" <greg at krypto.org> a écrit :
> Yes, see the followup.  My comments before were all misinterpreting
> size_t.
> Same result on x86_64 linux. On a 64-bit platform the 24 byte
> structure now occupies 24 bytes instead of being padded to 32.
> Nice.  On a 32-bit platform it should remain 16 bytes.

But you are losing the 16-byte alignment that the union was precisely
designed to enforce.

> The PyGC_Head union structure is NOT part of the ABI laid out in
> http://www.python.org/dev/peps/pep-0384/ and is accurately excluded
> from the .h file when Py_LIMITED_API is defined so changing this in
> 3.4 should not be a problem.

Not an ABI problem in 3.4 indeed (except that it might break platforms
with strict alignment requirements).

It should be noted that the GC head isn't part of standard atomic types
(int, float, str...), so the memory gain will not be very noticeable



More information about the Python-Dev mailing list