Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 420805
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 12, 20262026-05-12T18:54:48+00:00 2026-05-12T18:54:48+00:00

According to a section in this presumably accurate book , A common use of

  • 0

According to a section in this presumably accurate book,

A common use of pipes is to read a
compressed file incrementally; that
is, without uncompressing the whole
thing at once. The following function
takes the name of a compressed file as
a parameter and returns a pipe that
uses gunzip to decompress the
contents:

 def open_gunzip(filename):
     cmd = 'gunzip -c ' + filename
     fp = os.popen(cmd)
     return fp

If you read lines from fp one at a
time, you never have to store the
uncompressed file in memory or on
disk.

Maybe I’m just interpreting this wrong, but I don’t see how this is possible. Python couldn’t have any means of pausing gunzip halfway through spitting out the results, right? I assume gunzip isn’t going to block until a line of output is read before continuing to output more lines, so some buffer has to be capturing all of this (whether inside the Python interpreter or in the OS, whether in memory or on disk), meaning the uncompressed file is being stored somewhere in full…right?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-12T18:54:48+00:00Added an answer on May 12, 2026 at 6:54 pm

    Your assumption is faulty. gunzip does not have to see the entire file to unzip it. Read the unzip file format. There’s a directory, with offsets to the individual components.

    It’s possible to unzip a file in pieces.

    “uncompressed file is being stored somewhere in full…right?”

    Not necessarily. Not sure why you’re assuming it or where you read it.

    All low-level I/O calls can block. The write in gunzip — when writing to a pipe — can block when the pipe buffer is full. That’s the way I/O to a pipe is defined. Pipe I/O blocks.

    Check the man pages for pipe for details.

    If a process attempts to read from an
    empty pipe, then read(2) will
    block until data is available. If
    a process attempts to write to a
    full pipe (see below), then write(2)
    blocks until sufficient data has
    been read from the pipe to allow the
    write to complete. Non-blocking
    I/O is possible by using the fcntl(2)
    F_SETFL operation to enable the
    O_NONBLOCK open file status flag.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

According to this section in the Django docs I should use {% blocktrans %}
According to this , you can make use of xs:key and xs:keyref when marshalling
According to RFC959: FILE TRANSFER PROTOCOL (FTP) (section 4.1.1): Servers may allow a new
According to section 4.9.6.1 of the C89 draft , %d is a character that
I have a section in my GUI that is generated dynamically according to a
According to this section of the Hibernate documentation I should be able to query
Please have a look on this image The whole review section will slide according
I installed jsctags , but when I use it according to its usage section
According to MSDN (Section 11.3.6 of the C# spec ): Within an instance constructor
According to the ECMAScript specification in section 7.8.1 a NullLiteral is defined as follows:

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.