i = np.arange(2 * 2).reshape(2, 2) # array([[0, 1], # [2, 3]]) k = i.tobytes() # b'x00x00x00x00x01x00x00x00x02x00x00x00x03x00x00x00' y = np.frombuffer(k, dtype=i.dtype) # array([0, 1, 2, 3])