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

Gregory P. Smith greg at krypto.org
Fri Dec 14 10:14:04 CET 2012


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.

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.  This structure occupies the space gc tracked PyObject*
pointers.

-gps


On Fri, Dec 14, 2012 at 12:42 AM, Mark Dickinson <dickinsm at gmail.com> wrote:

> On Fri, Dec 14, 2012 at 7:27 AM, Gregory P. Smith <greg at krypto.org> wrote:
> > So changing the definition of the dummy side of the union makes zero
> > difference to already compiled code as it (a) doesn't change the
> structure's
> > size and (b) all existing implementations already align these on an 8
> byte
> > boundary.
>
> It looks to me as though the struct size *is* changed, at least on
> some platforms.  Before this commit, I get (OS X 10.6, 64-bit
> non-debug build):
>
> Python 3.4.0a0 (default:b4c383f31881+, Dec 14 2012, 08:30:39)
> [GCC 4.2.1 (Apple Inc. build 5664)] on darwin
> Type "help", "copyright", "credits" or "license" for more information.
> >>> class A(object): pass
> ...
> >>> a = A()
> >>> import sys
> >>> sys.getsizeof(a)
> 64
>
>
> After it:
>
> Python 3.4.0a0 (default:76bc92fb90c1+, Dec 14 2012, 08:33:48)
> [GCC 4.2.1 (Apple Inc. build 5664)] on darwin
> Type "help", "copyright", "credits" or "license" for more information.
> >>> class A(object): pass
> ...
> >>> a = A()
> >>> import sys
> >>> sys.getsizeof(a)
> 56
>
> --
> Mark
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-dev/attachments/20121214/1e21b679/attachment.html>


More information about the Python-Dev mailing list