I want to upload a numpy array to S3 using the boto3 package which expects a bytes object. I want to convert this numpy array to bytes but without any copying due to memory constraints. Things I tried that do not work because they create copies:
numpy.ndarray.tobytes,numpy.ndarray.tostringbytes(arr)io.BytesIO(arr)io.BytesIO(memoryview(arr))
It seems numpy used to provide numpy.ndarray.getbuffer but it was deprecated in later releases.
Is there a way to create a bytes view without copying?