I have a binary file and I am parsing it to a numpy array in Python
like the following:
bytestream= np.fromfile(path, dtype=np.int16)
for a in range(sizeA):
for x in range(0, sizeX):
for y in range(0, sizeY):
for z in range(0, sizeZ):
parsed[a, x, y, z] = bytestream[z + (sizeZ * x) + (sizeZ * sizeX * y) + (sizeZ * sizeX * sizeY * a)]
However, this is very very slow. Can anyone tell me why and how to speed it up?