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 · PULL REQUEST
py/objarray: Allow to create memoryview with offset/length.
py-core
Constructor signature is extended to:
memoryview(buf, offset, size)
This is equivalent to:
m = memoryview(buf)
m[offset:offset + size]
But allocates just 1 memoryview object instea of 2.
Also, .init(buf, offset, size) method added, which allows to reuse
(without allocation) existing memoryview object for new buffer object
(or to update "window" of memoryview into the buffer).
Change-Id: I1f864b908642b256305dc5caebf30662c306b1e0