-
Notifications
You must be signed in to change notification settings - Fork 75
Issue #16: accept arbitrary buffer-compatible objects #38
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
Issue #16: accept arbitrary buffer-compatible objects #38
Conversation
Merge development branch
Merge development branch
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks great, many thanks for this! One small nitpick, and one request: could you update the docstring accordingly for the source parameter to indicate that it will now accept any object supporting the buffer interface.
lz4/block/_block.c
Outdated
PyErr_Format(PyExc_OverflowError, "input too large for C 'int'"); | ||
return NULL; | ||
} | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pedantic: please be consistent with error message capitalization - "Input.."
You're welcome. I think I've now made the changes you asked for. |
Also, would be super awesome if you could rebase it on top of the development branch. |
…into accept_buffer_objects
Ok, I think I've rebased now (actually merged). |
Looks like format |
(if I may suggest so, you could simply drop Python 3.2 or even 3.3 compatibility, I don't think anybody would notice :-)) |
Yup - had noticed, just hadn't gotten around to removing 3.2 from the travis and appveyor configs :) Thanks again for your work on this. |
Current versions of the lz4 binding don't support memoryview inputs, but later versions should (see python-lz4/python-lz4#38).
* lz4: first try passing memoryview Current versions of the lz4 binding don't support memoryview inputs, but later versions should (see python-lz4/python-lz4#38). * Add tests * Add comment about blosc * always use blosc on memoryviews if available
This removes hand-written checks for bytes and bytearray, and instead uses the buffer API which allows for arbitrary buffer-compatible types. This is similar to what standard library modules like
zlib
already do.Incidentally, this also makes it possible to pass in a Numpy array without copying it to a bytes object first (see #35).