En Thu, 15 Oct 2009 15:07:04 -0300, pjcoup <pjc...@gmail.com> escribió:

import struct
struct.calcsize('BhhhhB')
11
struct.calcsize('@BhhhhB')
11
struct.calcsize('<BhhhhB')
10
struct.calcsize('>BhhhhB')
10

I would have expected calcsize('BhhhhB') to be either 10 or 12
(padding), but 11?

There are no pad bytes following the last member; from the docs:

"""Hint: to align the end of a structure to the alignment requirement of a particular type, end the format with the code for that type with a repeat count of zero. For example, the format 'llh0l' specifies two pad bytes at the end, assuming longs are aligned on 4-byte boundaries. This only works when native size and alignment are in effect; standard size and alignment does not enforce any alignment."""

py> calcsize("BhhhhB")
11
py> calcsize("BhhhhB0h")
12

--
Gabriel Genellina

--
http://mail.python.org/mailman/listinfo/python-list

Reply via email to