title: Decompress streaming BZ2 from memory in Python
body: <p>I have a block of CSV data bz2 compressed data in memory</p>
  
  <pre><code>compressed = load_from_network_service(...)
  </code></pre>
  
  <p>I would like to iterate over a stream of decompressed lines.</p>
  
  <pre><code>for line in bz2_decompress_stream(compressed):
      ...
  </code></pre>
  
  <p>Does such a function exist?</p>
  
  <p>In principle I could write to disk then read in using <code>bz2.BZ2File</code>, which only seems to want to consume a filename</p>
  
  <pre><code>with open('tmp', 'w') as f: 
      f.write(compressed)
  with bz2.BZ2File('tmp') as f:
      for line in f:
          ...
  </code></pre>
  
  <p>But, for my current application disk I/O is a premium, so this is a pain.</p>
  
  <p>Presumably the <code>bz2.BZ2Decompressor</code> object might be helpful here.  My experience with it is that I give it my compressed data and it gives me the entire decompressed result; it doesn't seem to stream.  Perhaps this is a limitation of my data?</p>