finding byte order

biner biner.sebastien at ouranos.ca
Fri Dec 3 11:54:31 EST 2004


Hello,

  I am using a program that has to read binary data from files coming
from different machines. The file are always written with big endian.
I am using the struct module to read the data and it is fine because I
can specify in the format if the data are to be read with big or small
endian convention.

  I would like to use the array module instead of struct because it is
suppose to be faster for big arrays. However, this module does not
provide a format specifier to say if the data are writtent with big or
small endian. The result is that it works on big-endian machine and
not on small-endian machine.

  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?

Thanks!



More information about the Python-list mailing list