How to convert numpy arrays to bytes/BytesIO without copying?

Viewed 923

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:

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?

0 Answers
Related