byteswap() looks like a general endian solution for ndarrays: https://stackoverflow.com/questions/49578507/fast-way-to-reverse-float32-end... numpy.memmap(infile, dtype=numpy.int32).byteswap().tofile(outfile) numpy.memmap(infile, dtype=numpy.int32).byteswap(inplace=True).flush() Bill -- Phobrain.com On 2023-01-01 08:31, Jerome Kieffer wrote:
On Sun, 01 Jan 2023 05:31:55 -0800 Bill Ross
wrote: Thanks!
Java is known to be big-endian ... your CPU is probably little-endian. $ lscpu | grep -i endian Byte Order: Little Endian
Numpy has the tools to represent an array of double BE. Is there a lower-level ndarray method that writes an array that could be used this way?
One example:
numpy.array([1,2,3], dtype=">d").tobytes()
b'?\xf0\x00\x00\x00\x00\x00\x00@\x00\x00\x00\x00\x00\x00\x00@\x08\x00\x00\x00\x00\x00\x00'
numpy.array([1,2,3], dtype="