Problem with unpack hex to decimal

Peter Hansen peter at engcorp.com
Sun Apr 17 16:59:19 EDT 2005


Jonathan Brady wrote:
> ... I also find the following confusing:
>>>>struct.calcsize('hb')
> 3
> 
>>>>struct.calcsize('hb') == struct.calcsize('bh')
> False
> 
> I could understand aligning to multiples of 4, but why is 'hb' different 
> from 'bh'? 

Pad bytes have never been, as far as I know, added
at the end of structs in C, only between fields, when
required.  So the leading "b" gets a following pad
byte, but the trailing one doesn't need padding.

-Peter



More information about the Python-list mailing list