|| at Dec 8, 1999 at 8:00 am
Travis Oliphant wrote:
Hi, I was wondering how to get my data to be represented in little
endian format. I know that I can use the socket functions to convert to
network byte order (big endian), but I need to convert to little endian
(not just the host byte order).
One possibility is to use the NumPy extensions and store your data in a
multiarray object. There is a byteswapped method of the multiarray object
that lets you byteswap your data.
footnote: the standard array module also provides
a byteswap operation:
a = array.array("i", [1, 2])
array('i', [1, 2])
array('i', [16777216, 33554432])
There is also a way to check the endianness of your machine (so
you can determine whether or not to byteswap).
from array-example-4.py in the eff-bot guide: