Return-Path: X-Original-To: python-list@python.org Delivered-To: python-list@mail.python.org X-Spam-Status: OK 0.022 X-Spam-Evidence: '*H*': 0.96; '*S*': 0.00; '22,': 0.09; 'dan': 0.09; 'false.': 0.09; 'tests,': 0.09; 'cc:addr:python-list': 0.11; 'from:addr:rosuav': 0.16; 'from:name:chris angelico': 0.16; 'merged': 0.16; 'sockets': 0.16; 'tcp': 0.16; 'wrote:': 0.18; 'wed,': 0.18; '(but': 0.19; '>>>': 0.22; 'input': 0.22; 'cc:addr:python.org': 0.22; 'affects': 0.24; 'byte': 0.24; 'bytes': 0.24; 'certainly': 0.24; 'mon,': 0.24; 'cc:2**0': 0.24; 'developers': 0.25; 'header:In-Reply-To:1': 0.27; 'related': 0.29; "doesn't": 0.30; 'important.': 0.30; 'statement': 0.30; 'message- id:@mail.gmail.com': 0.30; 'with,': 0.31; 'becomes': 0.33; 'maybe': 0.34; 'could': 0.34; "can't": 0.35; 'something': 0.35; 'no,': 0.35; "who's": 0.35; 'but': 0.35; 'received:google.com': 0.35; 'really': 0.36; 'doing': 0.36; 'should': 0.36; 'application': 0.37; 'two': 0.37; 'pm,': 0.38; 'anything': 0.39; 'does': 0.39; 'show': 0.63; 'soon': 0.63; 'our': 0.64; 'provide': 0.64; 'more': 0.64; 'series': 0.66; 'between': 0.67; '20,': 0.68; 'actually,': 0.84; 'to:none': 0.92 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:date:message-id:subject:from:cc :content-type; bh=aolLC6JIw2sG8505i2WXJDShYSgUezXmmyw2EFP1w+A=; b=cUBYx2aN1bFkru8IEHtpkZ77LnRGdZim+gV/78qyH0kv/4Gp4nAbKdwwMIU0ykwoxZ 0E6IJluFTIsaUQd4+2iB+fMs7LDKvDKNpHKgH9zvXInnx9KXWW/x2CxqxtTwDtR0fM7d YkG5X/zPtqBKz3E59sGnEa7fRsm0bmV4sVB2yBgt8BJTH6epZK4usaq0VwcyKVz0PABn G8vwyJmqHmBOOeu50T0x8OhXB04IAzUTGqg1gi8NZpHLj0hbPb7H2o5c3sxaEvZDygVA j+WNgiIVAHm3pyX1m3RhTwmSuiIcLKgM8Ga12f/wkAGYc7fBO+6AtJBdLEVZ6WR78iwT no2A== MIME-Version: 1.0 X-Received: by 10.50.60.97 with SMTP id g1mr32591837igr.2.1413958995171; Tue, 21 Oct 2014 23:23:15 -0700 (PDT) In-Reply-To: <871tq0fyun.fsf@elektro.pacujo.net> References: <87a94rgxi5.fsf@elektro.pacujo.net> <87mw8qfhza.fsf@elektro.pacujo.net> <87h9yyf318.fsf@elektro.pacujo.net> <871tq0fyun.fsf@elektro.pacujo.net> Date: Wed, 22 Oct 2014 17:23:15 +1100 Subject: Re: Flush stdin From: Chris Angelico Cc: "python-list@python.org" Content-Type: text/plain; charset=UTF-8 X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: General discussion list for the Python programming language List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Newsgroups: comp.lang.python Message-ID: Lines: 34 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1413959003 news.xs4all.nl 2965 [2001:888:2000:d::a6]:54228 X-Complaints-To: abuse@xs4all.nl Path: csiph.com!usenet.pasdenom.info!bete-des-vosges.org!feed.ac-versailles.fr!nerim.net!novso.com!newsfeed.xs4all.nl!newsfeed2a.news.xs4all.nl!xs4all!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail Xref: csiph.com comp.lang.python:79413 On Wed, Oct 22, 2014 at 4:38 PM, Marko Rauhamaa wrote: > Dan Stromberg : > >> On Mon, Oct 20, 2014 at 9:41 PM, Marko Rauhamaa wrote: >>> Nagle affects the communication between the peer OS kernels and isn't >>> directly related to anything the application does. >> >> Actually, Nagle can cause two or more small packets to be merged, >> which is something an application must be able to deal with, because >> they could show up in the receiving application as one or more (but >> anyway: fewer) merged recv()'s. > > Packets have barely anything to do with TCP sockets since they provide > an octet stream abstraction. TCP does abstract over the individual packets, but they are still important. >> Of course, but who's doing one byte per second? You and I in our >> tests, and perhaps some application developers with remarkably >> undemanding I/O. That doesn't really mean we should _recommend_ a >> series of os.read(0, 1)'s. > > No, here's my statement: if you need to process input as soon as it > becomes available, you can't use sys.stdin. Instead, you need to use > os.read(). > > You typically supply os.read() with a buffer of a kilobyte or more. Key > is, os.read() returns right away if fewer bytes are available. Then your statement is false. Maybe it's not *efficient* if you always use sys.stdin.read(1), but you certainly can do it. It's not that you *need to* use something else. ChrisA