-
Notifications
You must be signed in to change notification settings - Fork 1.5k
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
[Optimization request] Support buffers #2691
Comments
Since cffi doesn't support it, I don't really see how it'd be possible for us. |
CFFI doesn't allow memoryview directly, but using pointer arithmetic on the underlying bytes object you can get around that, as far as I could tell? |
Can you show an example of what you're talking about? At first glace, this sounds incredibly subtle and non-portable. |
It is incredibly non-portable and should be carefully wrapped in I'll submit an example patch for one of the functions. |
Okay, it looks like it's actually impossible for two reasons:
Too bad, it would have been really nice. |
Following the the mail link in the original post and referenced cffi issues, it seems that CFFI had finished some further development since then. |
As of cryptography 2.5 we support the buffer protocol for many key inputs (and we have |
Great! It's a coincidence that I was looking into the dsa sign and verify part and totally missed |
Can you support buffer objects, in particular allow read access to memoryview on bytes in CPython only? My understanding is that the CFFI disallows use of memoryview on bytes because it wants to present a uniform interface for PyPy, but indexing into the underlying bytes object actually works fine as long as you know you're on CPython.
Discussion here links to some bugs that were open at the time: https://mail.python.org/pipermail/cryptography-dev/2015-December/000532.html
This would reduce the number of copies from 2-3 to 1 and allow streaming/chunked interaction with encryption and decryption.
This would be a CPython-only improvement.
The text was updated successfully, but these errors were encountered: