Path: csiph.com!usenet.pasdenom.info!aioe.org!news.stack.nl!newsfeed.xs4all.nl!newsfeed3a.news.xs4all.nl!xs4all!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail Return-Path: X-Original-To: python-list@python.org Delivered-To: python-list@mail.python.org X-Spam-Status: OK 0.007 X-Spam-Evidence: '*H*': 0.99; '*S*': 0.00; 'context': 0.07; "ain't": 0.09; 'dan': 0.09; 'second.': 0.09; 'character.': 0.16; 'exception:': 0.16; 'from:addr:cs': 0.16; 'from:addr:zip.com.au': 0.16; 'from:name:cameron simpson': 0.16; 'message- id:@cskk.homeip.net': 0.16; 'received:211.29': 0.16; 'received:211.29.132': 0.16; 'received:cskk.homeip.net': 0.16; 'received:homeip.net': 0.16; 'received:optusnet.com.au': 0.16; 'received:syd.optusnet.com.au': 0.16; 'simpson': 0.16; 'to:name:python list': 0.16; 'wrote:': 0.18; '>>>': 0.22; 'header :User-Agent:1': 0.23; 'byte': 0.24; 'commands,': 0.24; 'cheers,': 0.24; 'developers': 0.25; 'script': 0.25; 'switch': 0.26; 'header :In-Reply-To:1': 0.27; "doesn't": 0.30; 'says': 0.33; 'not.': 0.33; "who's": 0.35; 'but': 0.35; 'there': 0.35; 'really': 0.36; 'received:com.au': 0.36; 'doing': 0.36; 'charset:us-ascii': 0.36; 'should': 0.36; 'application': 0.37; 'received:211': 0.38; 'to:addr:python-list': 0.38; 'issue': 0.38; 'to:addr:python.org': 0.39; 'read': 0.60; 'content-disposition:inline': 0.62; 'our': 0.64; 'more': 0.64; 'between': 0.67; 'line,': 0.68; 'therefore': 0.72; 'upstream': 0.84; 'write()': 0.91 Date: Wed, 22 Oct 2014 10:46:56 +1100 From: Cameron Simpson To: Python List Subject: Re: Flush stdin MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii; format=flowed Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.5.21 (2010-09-15) References: X-Optus-CM-Score: 0 X-Optus-CM-Analysis: v=2.1 cv=dMCfxopb c=1 sm=1 tr=0 a=YuQlxtEQCowy2cfE5kc7TA==:117 a=YuQlxtEQCowy2cfE5kc7TA==:17 a=ZtCCktOnAAAA:8 a=PO7r1zJSAAAA:8 a=LcaDllckn3IA:10 a=r5UFkecV8NkA:10 a=kj9zAlcOel0A:10 a=vrnE16BAAAAA:8 a=pGLkceISAAAA:8 a=YGhtmgN2iHRK4f7cTtcA:9 a=CjuIK1q_8ugA:10 a=MSl-tDqOz04A:10 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: 25 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1413936371 news.xs4all.nl 2841 [2001:888:2000:d::a6]:54488 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:79406 On 21Oct2014 16:16, Dan Stromberg wrote: [...snip...] >>> This is tremendously inefficient. It demands a context switch for >>> every character. >> >> Inefficiency isn't an issue when you generate one byte a second. > >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. Indeed not. But there is one glaring exception: the shell's read builtin. Because it can be interspersed in a script between other input-consuming commands, it _must_ read no more than one line, and therefore is has to read in increments of 1 character. Of course, that says nothing about the upstream write() granularity. I now return y'all to your regularly sheduled nit picking. Cheers, Cameron Simpson If it ain't broken, keep playing with it.