struct curiosity

Richard Brodie R.Brodie at
Fri Oct 16 11:55:05 CEST 2009

"pjcoup" <pjcoup at> wrote in message 
news:b1537079-6e3a-43e1-814b-7ccf185fb9c3 at

> I would have expected calcsize('BhhhhB') to be either 10 or 12
> (padding), but 11?  Is there a simple explanation of what is going
> on here?

The purpose of the padding is to align the words 'naturally'.
That is, when reading two bytes, to start at an even number.

B   X         B   h1
h1  h1        h1  h2
h2  h2        h2  h3
h3  h3        h3  h4
h4  h4        h4  B
B   Y

The padding at X lines up h1-h4. There isn't any point
putting padding at Y. 

More information about the Python-list mailing list