title: How to construct a TarFile object in memory from byte buffer in Python 3?
body: <p>Is it possible to create a TarFile object in memory using a buffer containing the tar data without having to write the TarFile to disk and open it up again? We get the bytes sent over a socket.</p>
  
  <p>Something like this:</p>
  
  <pre><code>import tarfile
  byte_array = client.read_bytes()
  tar = tarfile.open(byte_array) # how to do this?
  # use "tar" as a regular TarFile object
  for member in tar.getmembers():
      f = tar.extractfile(member)
      print(f)
  </code></pre>
  
  <p>Note: one of the reasons for doing this is that we eventually want to be able to do this with multiple threads simultaneously, so using a temp file might be overridden if two threads try to do it at the same time.</p>
  
  <p>Thank you for any and all help!</p>