A bug in struct module on the 64-bit platform?

Fredrik Lundh fredrik at pythonware.com
Thu Dec 1 18:18:56 CET 2005

Neal Norwitz wrote:

>> I have a user who complained about how "struct" module computes C
>> struct data size on Itanium2 based 64-bit machine.
> I wouldn't be surprised, but I don't understand the problem.
>>    >>struct.calcsize('idi')
>>    16
>>    >>struct.calcsize('idid')
>>    24
>>    >>struct.calcsize('did')
>>    20
> These are what I would expect on a 32 or 64 bit platform.  i == int, d
> == float.  ints are typically 4 bytes on 64 bit platforms.  If you want
> 8 byte integers, you typically need to use longs (format letter is ell,
> l).

except that the 64-bit double should, on most 64-bit platforms, have
64-bit alignment, so


should be 4 bytes integer plus 4 bytes padding plus 8 bytes double plus
4 bytes integer, or 20 bytes.

I'd expect


but I have no 64-bit box within reach just now...

or isn't "native alignment" the default?


More information about the Python-list mailing list