struct.pack behavior

Gabriel Genellina gagsl-py2 at yahoo.com.ar
Wed Jun 25 23:13:00 EDT 2008


En Wed, 25 Jun 2008 23:38:54 -0300, Steven Clark  
<steven.p.clark at gmail.com> escribi�:

> On Wed, Jun 25, 2008 at 7:03 PM, John Machin <sjmachin at lexicon.net>  
> wrote:
>> On Jun 26, 9:00 am, "Steven Clark" <steven.p.cl... at gmail.com> wrote:
>>> Can anyone explain to me why
>>> struct.pack('HB',1,2) gives 3 bytes, whereas struct.pack('BH',1,2)
>>> gives 4 bytes?
>>>
>> Alignment -- read the manual.
>
> If "the manual" is the help files for the struct module, I've read it
> several times over. I understand endianness; I don't understand
> alignment. Could anyone give a less cryptic / terse answer?

A good start might be this Wikipedia article:  
<http://en.wikipedia.org/wiki/Data_structure_alignment>

-- 
Gabriel Genellina




More information about the Python-list mailing list