I am doing some socket IO, and using a bytearray object as a buffer. I would like to receive data with an offset into this buffer using csock.recv_into as shown below in order
Use a memoryview to wrap your bytearray:
memoryview
bytearray
buf = bytearray(toread) view = memoryview(buf) while toread: nbytes = sock.recv_into(view, toread) view = view[nbytes:] # slicing views is cheap toread -= nbytes