struct curiosity
Richard Brodie
R.Brodie at rl.ac.uk
Fri Oct 16 05:55:05 EDT 2009
"pjcoup" <pjcoup at gmail.com> wrote in message
news:b1537079-6e3a-43e1-814b-7ccf185fb9c3 at v15g2000prn.googlegroups.com...
> 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