finding byte order

Diez B. Roggisch deetsNOSPAM at web.de
Fri Dec 3 13:19:48 EST 2004


>   I would like to have a test to tell me if the current machine is
> using big or small endian, this way I could use the array module in
> the first case and the *slower* struct module on the second. I looked
> but did not find. Is there a python function to know that?

There is no such test, as it's domain-specific if there _can_ be such a test
or not. If your data is composed in a way that you can infer the endianess
by reading e.g. a header at the beginning that has well-known fields, then
it might work. But only you can do that.

For a pure binary file, there is absolutely no way of telling the endianess.
-- 
Regards,

Diez B. Roggisch



More information about the Python-list mailing list