title: How to obtain random access of a gzip compressed file
body: <p>According to <a href="http://www.zlib.net/zlib_faq.html#faq28" rel="nofollow">this FAQ on zlib.net</a> it is possible to:</p>
  
  <blockquote>
    <p>access data randomly in a compressed stream</p>
  </blockquote>
  
  <p>I know about the module Bio.bgzf of <a href="http://news.open-bio.org/news/2012/06/biopython-1-60-released/" rel="nofollow">Biopyton 1.60</a>, which:</p>
  
  <blockquote>
    <p>supports reading and writing BGZF files (Blocked GNU Zip Format), a variant of GZIP with efficient random access, most commonly used as part of the BAM file format and in tabix. This uses Python’s zlib library internally, and provides a simple interface like Python’s gzip library.</p>
  </blockquote>
  
  <p>But for my use case I don't want to use that format. Basically I want something, which emulates the code below:</p>
  
  <pre><code>import gzip
  large_integer_new_line_start = 10**9
  with gzip.open('large_file.gz','rt') as f:
      f.seek(large_integer_new_line_start)
  </code></pre>
  
  <p>but with the efficiency offered by the native zlib.net to provide random access to the compressed stream. How do I leverage that random access capability in Python?</p>