Support for memoryview and bytearray objects
ericpruitt opened this issue · 6 comments
It would be nice if the library supported bytearray and memoryview objects for users that want to reduce the amount of copying that takes place when working with slices of data.
I don't have the available bandwidth to implement this myself, but I'll happily include patches adding support for those objects.
Are you going to require that I add support for Python 2, and are you willing to accept a incremental patches? The filesystem I'm currently developing with FUSE is read-only, and although I could potentially add support for write operations, I don't have anything that I could use to exercise it other than in some trivial cases, and I don't want to contribute code I can't properly test.
At some point I'll drop support for python2 anyway. It may as well be when welcoming a serious functional contribution, so don't bother with python2 on your end. Incremental support, first for RO operations then later for RW, is fine.
I opened #62. As mentioned in the PR, it's not zero-copy in its current form. Let's continue the discussion there if you have anything to add.
Looking at the write logic, I'm not sure it makes sense to implement support for the buffer protocol for writes. When the data reaches the user in Python, it will always be in bytes which support the buffer protocol. This means that, if the user casts that data to a memoryview, Python doesn't do an additional copy anyway, instead maintaining a reference to the object returned without doing any further duplication.