array.array
is only useful for internal calculations, because it always uses the native byte order. There is a method byteswap
to change the order. Therefore you have to check sys.byteorder
to determine the system byteorder, and swap accordingly.
To have better control of ordering use struct
:
data = f.read()
c = struct.unpack_from('<8H', data, 16)