-
Notifications
You must be signed in to change notification settings - Fork 105
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
Can snappy.decompress(buffer) but cannot snappy.decompress(memoryview) #65
Comments
@andrix , given that this code was written a good while ago, is there now scope for supporting memoryviews directly? |
hey @martindurant - I would need to research, it has been a long time. Currently, it expects a I don't have enough time atm to research on how |
The memoryview support should be a simple matter of switching from |
@himikof , would you like to put this into a PR? |
Sure. You'll want to use the buffer protocol for everything that is passing raw binary data around. This ensures the maximum compatibility with all Python types that deal with binary data ( See https://github.com/indygreg/python-zstandard/blob/52fb4fba88993ffaf983da109b2696d07f14074d/c-ext/compressor.c#L491 for how a function should accept an object conforming to the buffer protocol. When you use When you use Note that If you aren't sure your function is receiving an object that conforms to the buffer protocol, you can use That's the reading side. You can also have your custom types implement the buffer protocol so other consumers can use Unless you need to invent a custom type for representing binary data, you probably don't need to implement the buffer protocol on any of your types though. I hope this was useful. |
I would be grateful if someone please submit a pull request on this one. I do not understand this area well enough to create such a PR myself but would be very interested to see a fix put in place. |
Is there a way to make snappy.decompress() work directly on a memoryview without casting it to another datatype? Casting makes a copy of the data which is undesirable in our case.
https://github.com/cclauss/snappy-hack/blob/master/snappy_hack.py
The text was updated successfully, but these errors were encountered: