QUERY · ISSUE
Add .offset()/.seek() method for memoryview for inplace "slicing"
enhancementrfc
Here's an idiom to send a large data buffer thru a short-write stream (e.g., non-blocking socket):
buffer = memoryview(data).cast('b')
while buffer:
try:
nsent = self._socket_send(buffer, flags)
buffer = buffer[nsent:]
The last statement still produces bunch of object garbage. If we could do
buffer.offset(nsent)
it would be cool. Suggestions for better name are welcome.
CANDIDATE · ISSUE
Support for buffer protocol in btree module
enhancement
Allowing btree module to get binary data as memoryview and bytearray will deduplicate RAM allocation for converting memoryview and bytearray to bytes.
import btree
db = btree.open(open("mydb", "w+b"))
db[memoryview(b"test_key")] = memoryview(b"test_value")
Currently the snippet generates this exception :
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
TypeError: can't convert 'memoryview' object to str implicitly