title: Reading a gzip file backwards
body: <p>I want understand what is the most efficient (speed and performance) way to read a gzip file backwards without loading the contents of the entire file in to memory. </p>
  
  <p>Here is what I do currently, but is not efficient for really large files:</p>
  
  <pre><code>file = 'huge_file.log.gz'
  import gzip
  if file.endswith('gz'):
      f = gzip.open(file)
      # reverse the file contents
      reverse_file_list = reversed(f.read().decode('utf-8').split('\n'))
  </code></pre>
  
  <p>I see there are some solutions in stackoverflow and codestate which do negative seeks but negative seeks are not supported when files are opened in binary mode as with gzip.open</p>
  
  <p>Links:
  <a href="https://stackoverflow.com/questions/260273/most-efficient-way-to-search-the-last-x-lines-of-a-file-in-python/260433#260433">Most efficient way to search the last x lines of a file in python</a></p>
  
  <p><a href="http://code.activestate.com/recipes/439045/" rel="nofollow noreferrer">http://code.activestate.com/recipes/439045/</a> </p>
  
  <p>So the solution fails for what I want to accomplish.</p>