[BangPypers] Python's stdin buffer size

Senthil Kumaran senthil at uthcode.com
Wed Dec 21 16:28:24 CET 2011


On Wed, Dec 21, 2011 at 7:43 PM, Amit Sethi
<amit.pureenergy at gmail.com> wrote:> Hi , I am trying to read in a
large message piped to a python script.> The message would have
something like 1000 words . How can one> increase the buffer size of
sys.stdin in python.
For 1000 words, your python program wont have any problem. PIPE is a
OS property and Operating System kernel will take care of buffering
enough of data so that your consuming python program can read. That's
how it operates in Python 2.7 where the input size is effectively
managed by OS kernel.

>From 3.x onwards, a buffered reader class is provided by Cpython,
wherein you can give an argument to sys.stdin.buffer.read(200000)
which would read that many bytes. If you are not using 3.x, perhaps
you may not care of about this.

Senthil


More information about the BangPypers mailing list