Struct usage and varying sizes of h, l, etc

Matthieu Brucher matthieu.brucher at gmail.com
Wed May 21 08:32:47 EDT 2008


>
> This is all true if you want to operate in "native" mode; however in
> "standard" mode the sizes are fixed -- otherwise there'd be no easy way of
> reading/writing the fixed-size fields in many common file formats.
>
> As the manual says:
> """
> Native size and alignment are determined using the C compiler's sizeof
> expression. This is always combined with native byte order.
>
> Standard size and alignment are as follows: no alignment is required for
> any type (so you have to use pad bytes); short is 2 bytes; int and long are
> 4 bytes; long long (__int64 on Windows) is 8 bytes; float and double are
> 32-bit and 64-bit IEEE floating point numbers, respectively.
> """
>
> If, as I suspect, Ethan's purpose is be able to read/write files in a
> long-established PC file format, he will need to '<' for littleendian order,
> and an appropriate selection from bBhHiI and d will do what he needs.
>
> HTH,
> John


On an Ubuntu 64 box :

>>> struct.calcsize('l')
8

not 4.

Matthieu
-- 
French PhD student
Website : http://matthieu-brucher.developpez.com/
Blogs : http://matt.eifelle.com and http://blog.developpez.com/?blog=92
LinkedIn : http://www.linkedin.com/in/matthieubrucher
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-list/attachments/20080521/6e04fbbe/attachment-0001.html>


More information about the Python-list mailing list