I have read a binary file from disk. Which produces a bytes variable e.g.
arr = open(file, "rb").read()
Now arr is structured such that each 4-byte form a 32bit integer (little endian). I see there is function int.from_bytes to convert bytes to int but it is too slow.
Is there a function to convert bytes to an integer array? Numpy solutions welcome.
In contrast, this seems easy to do in R and Julia e.g.
In R
readBin(arr, what="integer", n=length(arr)/4)
In Julia
reinterpret(Int32, arr)
arraymodule. Format code for 4-byte signed ints is 'l'. The.frombytes()method for what you asked, or the.fromfile()method to construct directly by a reading from an open binary-mode file.