-
-
Notifications
You must be signed in to change notification settings - Fork 90
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 arbitrary buffer-like objects #26
Comments
Eh? I assume you are talking about Python 3, because Anyway, it is my intent for this to work. I /thought/ that using the Anyway, |
Yes, I would recommend to use (for the record, |
FWIW, I filed a docs bug at http://bugs.python.org/issue30625 because this limitation of |
I'm actively working on this. |
Without this, we may not accept all objects implementing the buffer protocol.
The y#/s# format unit don't appear to accept all types exposing a read-only bytes-like object. The Python docs do say that y*/s* is the recommended way to accept binary data. So we switch to that.
This is slightly more involved than other changes because of existing checking for unicode types. Python 2 happily allows unicode to be cast to a Py_buffer. Python 3 doesn't. So we need to update the test accordingly. The CFFI code has also been updated to use ffi.from_buffer() so it is consistent with the C code. And since this is the last function using y#/s# for argument parsing, update the NEWS.
And I pushed those commits to the master branch. Calling this one done. Thanks for the bug report and the background on |
The methods in this package (such as
ZStdCompressor.compress()
andZStdDecompressor.decompress()
) typically don't support bytearray or memoryview inputs. Though for some strange reason they seem to support Numpy arrays:Note that other compression libraries typically accept arbitrary buffer-like objects (which allows passing them without copying to bytes before):
The text was updated successfully, but these errors were encountered: