-
Notifications
You must be signed in to change notification settings - Fork 1.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
support memoryview in all places bytes, bytearray are supported #3423
Comments
Thanks @alonbl for the feature request. I brought this up for discussion with the team and it seemed like something they may be receptive to doing. However more research is required before confirming that decision. We encourage others to 👍 this issue if they are also interested and if there are any more details you can share regarding your use case please let us know. |
Thank you @tim-finnigan, While this discussion happening, please also consider receiving into buffers like the new method of |
A common use case is uploading a pandas df to AWS s3 without needing s3fs (for instance in corporate env with tight approvals), it's been asked several times on StackOverflow (a few examples 1 2 3). It's not limited to pandas though, there are many packages whose upload to s3 could be transformed from o = s3.Object("bucket", "key")
with BytesIO() as f:
df.to_csv(f)
o.put(f.getvalue()) or o = s3.Object("bucket", "key")
with BytesIO() as f:
df.to_csv(f)
f.seek(0)
o.upload_fileobj(f) to o = s3.Object("bucket", "key")
with BytesIO() as f:
df.to_csv(f)
o.put(f.getbuffer()) which would save a |
This would be very useful in piskvorky/smart_open#380, and I opened a PR where I made the suggested changes + added tests boto/botocore#3107. It really does seem to be as easy as changing a couple |
Hi folks, any movement here? This would be very helpful for us when uploading files without copies |
there's been zero comments or reviews on my PR (which I noticed I'd incorrectly linked in my last comment, oops), doesn't seem like there's much interest from maintainers. |
Describe the bug
Currently there are explicit checks for explicit types in boto3, for example:
botocore/validate.py
:In order to avoid copy
memoryview
class can be used to wrapbytearray
, passingmemoryview
is compatible withbytearray
, however, due to the validation check it fails.Expected Behavior
Accept
memoryview
wheneverbytes
orbytearray
are accepted.Current Behavior
Due to manual checks which were added in good intentions passing
memoryview
is rejected, as result we cannot avoid copy of large buffers.Reproduction Steps
Possible Solution
Modify the following (for example) all over the code:
Additional Information/Context
No response
SDK version used
botocore-1.27.75
Environment details (OS name and version, etc.)
python-3
The text was updated successfully, but these errors were encountered: