-
Notifications
You must be signed in to change notification settings - Fork 47
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
Add ability to read bytes from objc.varlist #205
Comments
Original comment by Ronald Oussoren (Bitbucket: ronaldoussoren, GitHub: ronaldoussoren). Adding as_bytes would be useful, and I'll look into this. I guess as_memoryview would be more useful because this could avoid copying data. Implementing the buffer protocol is not possible, this requires knowing the size of the buffer and that's something a varlist object doesn't do. |
Original comment by Ronald Oussoren (Bitbucket: ronaldoussoren, GitHub: ronaldoussoren). I'm adding method This makes it possible to directly write to the underlying memory through the buffer, just like you can write to that memory through the item setter of the varlist object. The user is responsible for checking if the memory is writable by checking the API documentation. |
Original comment by Ronald Oussoren (Bitbucket: ronaldoussoren, GitHub: ronaldoussoren). Add This fixes #205 |
Original comment by Ronald Oussoren (Bitbucket: ronaldoussoren, GitHub: ronaldoussoren). This will be in PyObjC 4.0, which will be released around High Sierra's release (if I read Apple's website correct High Sierra is released sept. 25, with the current state of the 10.13 branch that means PyObjC should be released sometime next week) |
Original comment by Ronald Oussoren (Bitbucket: ronaldoussoren, GitHub: ronaldoussoren). Removing version: 3.1 (automated comment) |
Original report by Nickolas Pohilets (Bitbucket: nickolas_pohilets, ).
Use case: CGBitmapContextGetData returns a pointer to raw data, several MBs in size. I would like to pass it to NumPy for further processing. Currently, it gets converted into a tuple of millions of single-byte objects.
A simple solution would be adding a method
def as_bytes(self, count: int) -> bytes
.Another alternative is to implement Buffer Protocol
The text was updated successfully, but these errors were encountered: