Native object exposing buffer protocol
On Saturday, January 6, 2018 at 12:02:18 AM UTC, Rob Gaddi wrote:
> I'd like to create a native Python object that exposes the buffer
> protocol. Basically, something with a ._data member which is a
> bytearray that I can still readinto, make directly into a numpy array, etc.
> I can do it by inheriting the entire thing from bytearray directly, but
> that gives me a whole lot of methods that are unsuitable for what I'm
> doing with it, which is reading the contents of a binary file, allowing
> them to be lightly malleable in memory, and then sending them on to a
> Not the end of the world (the file's less than 2KB), but it seems like
> something that should be doable easily without having to throw around a
> lot of extraneous copies.
> Rob Gaddi, Highland Technology -- www.highlandtechnology.com
> Email address domain is currently out of order. See above to fix.
Could you use memoryviews instead of making the copies?