Re: struct.pack behavior

2008-06-27 Thread Steven Clark
For efficiency reasons many CPUs require particular primitive data types (integers/pointers of various sizes) to be placed in memory at particular boundaries. For example, shorts (H above, usually two bytes and probably always so in the struct module) are often required to be on even

Re: struct.pack behavior

2008-06-26 Thread John Machin
On Jun 26, 12:38 pm, Steven Clark [EMAIL PROTECTED] wrote: On Wed, Jun 25, 2008 at 7:03 PM, John Machin [EMAIL PROTECTED] wrote: On Jun 26, 9:00 am, Steven Clark [EMAIL PROTECTED] wrote: Can anyone explain to me why struct.pack('HB',1,2) gives 3 bytes, whereas struct.pack('BH',1,2) gives

struct.pack behavior

2008-06-25 Thread Steven Clark
Can anyone explain to me why struct.pack('HB',1,2) gives 3 bytes, whereas struct.pack('BH',1,2) gives 4 bytes? -Steven -- http://mail.python.org/mailman/listinfo/python-list

Re: struct.pack behavior

2008-06-25 Thread John Machin
On Jun 26, 9:00 am, Steven Clark [EMAIL PROTECTED] 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. -- http://mail.python.org/mailman/listinfo/python-list

Re: struct.pack behavior

2008-06-25 Thread Steven Clark
On Wed, Jun 25, 2008 at 7:03 PM, John Machin [EMAIL PROTECTED] wrote: On Jun 26, 9:00 am, Steven Clark [EMAIL PROTECTED] 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. --

Re: struct.pack behavior

2008-06-25 Thread Gabriel Genellina
En Wed, 25 Jun 2008 23:38:54 -0300, Steven Clark [EMAIL PROTECTED] escribi�: On Wed, Jun 25, 2008 at 7:03 PM, John Machin [EMAIL PROTECTED] wrote: On Jun 26, 9:00 am, Steven Clark [EMAIL PROTECTED] wrote: Can anyone explain to me why struct.pack('HB',1,2) gives 3 bytes, whereas

Re: struct.pack behavior

2008-06-25 Thread Cameron Simpson
On 25Jun2008 22:38, Steven Clark [EMAIL PROTECTED] wrote: | On Wed, Jun 25, 2008 at 7:03 PM, John Machin [EMAIL PROTECTED] wrote: | On Jun 26, 9:00 am, Steven Clark [EMAIL PROTECTED] wrote: | Can anyone explain to me why | struct.pack('HB',1,2) gives 3 bytes, whereas struct.pack('BH',1,2) |