Re: Why is "for line in f" faster than readline()

2007-07-27 Thread Alexandre Ferrieux
On Jul 27, 2:16 pm, Duncan Booth <[EMAIL PROTECTED]> wrote: > Alexandre Ferrieux <[EMAIL PROTECTED]> wrote: > > Now, *why* is such buffering gaining speed over stdio's fgets(), which > > already does input buffering (though in a more subtle way, which makes > > it still usable with pipes etc.) ? >

Re: Why is "for line in f" faster than readline()

2007-07-27 Thread Duncan Booth
Alexandre Ferrieux <[EMAIL PROTECTED]> wrote: > Now, *why* is such buffering gaining speed over stdio's fgets(), which > already does input buffering (though in a more subtle way, which makes > it still usable with pipes etc.) ? > Because the C runtime library has different constraints than Pyth

Why is "for line in f" faster than readline()

2007-07-26 Thread Alexandre Ferrieux
Hi, In a recent thread I discovered why the "for line in f" idiom was not suitable for live sources (pipes, sockets, tty). The reason is that it uses buffering on input, blocking on a full buffer read before anything. When I asked why it did it this way, the answer came up that it made it faster.