[Python-ideas] Exact integral types in struct
Serhiy Storchaka
storchaka at gmail.com
Tue Mar 20 19:26:43 CET 2012
The struct module works only with natural platform-specific integers. As
a result, a lot of code in the standard library and third-party
applications are forced either to rely on unreliable assumptions (short
is always 2-byte, long is always 4-byte), which is not always true,
either explicitly construct the integer from bytes
(b[0]+(b[1]<<8)+(b[2]<<16)+...). I propose to introduce a special
notation formats for signed and unsigned integers of arbitrary exact
size (which is given a number preceded by the prefix). After that,
eliminate the use of platform-specific formats when working with
platform-independent data (such as zip, for example).
Or maybe I'm behind, and the corresponding functions already exist, and
the use of the struct module is only remnants?
More information about the Python-ideas
mailing list