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: Introduce "memview_offset" alias for "free" field of the…
… object.
Both mp_type_array and mp_type_memoryview use the same obejct structure,
mp_obj_array_t, but for the case of memoryview, some fields, e.g. "free",
have different meaning. As the "free" field is also a bitfield, assume
that (anonymous) union can't be uses here, and just a field alieas using
a #define. As it's a define, it should be a selective identifier, so use
verbose "memview_offset" to avoid any clashes.