title: Write data directly to a tar archive
body: <p>I am looking for a way in which I can pickle some Python objects into a combined tar archive. Further I also need to use <code>np.save(....)</code> to save some numpy arrays in yet the same archive. Of corse, I also need to read them later.</p>
  
  <p>So what I tried is </p>
  
  <pre><code>a = np.linspace(1,10,10000)    
  tar = tarfile.open(fileName, "w")
  tarinfo = tarfile.TarInfo.frombuf(np.save(a, fileName))
  tar.close()
  </code></pre>
  
  <p>and I get the error:</p>
  
  <pre><code>'numpy.ndarray' object has no attribute 'write'
  </code></pre>
  
  <p>Simlar problems I get if I pickle an object in the tar-file. Any suggestions? If it is easier, json-pickle would also work.</p>
  
  <p>EDIT: as mentioned in the comments I confused the arguments of np.save(). However, this does not solve the issue, as now I get the error:</p>
  
  <pre><code>object of type 'NoneType' has no len()
  </code></pre>
  
  <p>EDIT 2: If there is no solution to the above problem, do you know of any other way of time efficiently boundle files?</p>