What I Touched This Week 2017-04-16

This is a post in series "What I Touched"
Use a memoryview to wrap your bytearray:

buf = bytearray(toread)
view = memoryview(buf)
while toread:
    nbytes = sock.recv_into(view, toread)
    view = view[nbytes:] # slicing views is cheap
    toread -= nbytes
comments powered by Disqus