title: using bytearray with socket.recv_into
body: <p>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 to avoid creating intermediary string objects. Unfortunately, it seems bytearrays can't be used this way, and the code below doesn't work. </p>
  
  <pre><code>buf    = bytearray(b" " * toread)
  read   = 0
  while(toread):
    nbytes = csock.recv_into(buf[read:],toread)
    toread -= nbytes
    read   += nbytes
  </code></pre>
  
  <p>So instead I am using the code below, which <em>does</em> use a temporary string (and works)...</p>
  
  <pre><code>buf    = bytearray(b" " * toread)
  read   = 0
  while(toread):
    tmp = csock.recv(toread)
    nbytes = len(tmp)
    buf[read:] = tmp
    toread -= nbytes
    read   += nbytes
  </code></pre>
  
  <p>Is there a more elegant way to do this that doesn't require copying intermediate strings around?</p>