-
-
Notifications
You must be signed in to change notification settings - Fork 7
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
Implement PyBufferProtocol for RustyBuffer #48
Conversation
This is probably a performance improvement that you'd care about; good news, it's at least as fast as
|
@messense I had to drop I'll poke around and fix it myself if you didn't have time, just thought you probably already know more about this area. 😃 |
That's the one! |
Working on it. Edit: #49 |
Please ping me when this makes it into release. |
Also, quick question: did this happen to implement passing of python buffer-like objects as inputs too, for the origin of the compressed data and/or for the _into functions? Asking for curiosity. |
_maybe_open_or_copy_to_local is taking a disproportionate amount of time, considering no work should be happening within the function - but maybe the profiler is not able to follow the contexts very well. Is this is local cache or no? |
* CI: Add python-version matrix * CI: Fix linux cross build * CI: Use maturin 0.10 prerelease, it has i686 wheels
@martindurant Sure thing, I'll let you know!
Depends what you mean exactly; all variants, to include
I'm not sure what you mean, can you elaborate? |
That covers all possibilities except a raw buffer, any class supporting the low-level buffer API. I don't think that includes BytesIO anyway. Since the list has In [5]: np.frombuffer(io.BytesIO(b"\x00\x00"), dtype='uint8')
---------------------------------------------------------------------------
TypeError Traceback (most recent call last)
<ipython-input-5-28ba73ab06d2> in <module>
----> 1 np.frombuffer(io.BytesIO(b"\x00\x00"), dtype='uint8')
TypeError: a bytes-like object is required, not '_io.BytesIO'
In [6]: np.frombuffer(bytearray(b"\x00\x00"), dtype='uint8')
Out[6]: array([0, 0], dtype=uint8)
In [7]: np.frombuffer(memoryview(bytearray(b"\x00\x00")), dtype='uint8')
Out[7]: array([0, 0], dtype=uint8)
Freak paste into the wrong window, please ignore! |
FYI, PyO3 will support In the meantime, you can change it to |
Thanks for that, much better solution. 👌 |
RustyBuffer
RustyBuffer
(It's zero copy to usebytes
,bytearray
or others implementing buffer protocol to view the underlying bytes inRustyBuffer
, so the user can choose what they want to view it as)abi3
is not supported for implementingPyBufferProtocol