how many bytes in an int

Grant Edwards grante at visi.com
Mon Aug 9 10:41:52 EDT 2004


On 2004-08-09, Grant Edwards <grante at visi.com> wrote:

>> I think struct is really needed.
>
> Like the man said, "struct" doesn't convert to-from integers
> of specified byte lengths.  All it has are the C types "int"
> "long" "long long", etc.  There is no portable way using
> struct to request a 4-byte integer.

I like the "calcsize" suggestion for "portablizing" the struct
method.  Once at program startup you figure out what struct
formats you need for various lengths and Bob's your uncle.

-- 
Grant Edwards                   grante             Yow!  FIRST, I'm covering
                                  at               you with OLIVE OIL and
                               visi.com            PRUNE WHIP!!



More information about the Python-list mailing list