Skip to content
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

Feature: accept memoryview besides bytes #9

Closed
maartenbreddels opened this issue Sep 3, 2020 · 4 comments
Closed

Feature: accept memoryview besides bytes #9

maartenbreddels opened this issue Sep 3, 2020 · 4 comments

Comments

@maartenbreddels
Copy link

Hi,

thanks for this library, I was looking for something like blake3, so when I found it and found out there was a Python binding, that made me very happy :).

I was wondering if it would be simple to support memoryview instead of bytes. You can get a memoryview on a bytes object, so that would allow for less memory copies if I am not mistaken. Having a memoryview, and converting it to a bytes object (mv.tobytes()) does seem to do a memory copy.

Regards,

Maarten

@oconnor663
Copy link
Owner

There should already be support for memoryview. We test it here. Have you given it a try?

@maartenbreddels
Copy link
Author

Strange, I'll investigate tomorrow why I got these failures.

@oconnor663
Copy link
Owner

Please do. I'll be curious to see the error messages. In the meantime, I've pushed b69d1ba to add a small comment about this to the readme example.

maartenbreddels added a commit to maartenbreddels/blake3-py that referenced this issue Sep 11, 2020
maartenbreddels added a commit to maartenbreddels/blake3-py that referenced this issue Sep 11, 2020
oconnor663 pushed a commit that referenced this issue Sep 12, 2020
As part of this, refactor hash_bytes_using_buffer_api() to use
PyBuffer::as_slice, so that we don't need to check for contiguity
ourselves.

Fixes #9.
@oconnor663
Copy link
Owner

This auto closed because of my commit message, but I do want to test it. The easiest way to import the local build is to do:

$ cd blake3-py/test
$ ./build.py
...
$ python
>>> import blake3
>>> blake3.__file__
'[path to your blake3-py clone]/tests/blake3.so'

I've checked that pyarrow seems to work with my latest changes on master, but please let me know if you have time to repro.

oconnor663 pushed a commit that referenced this issue Sep 12, 2020
Changes since 0.1.6:
- Add support for hashing buffers of signed chars. This is uncommon,
  but it can come up with e.g. PyArrow. See
  #9 and
  #11.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants