[Python-Dev] RE: [Patches] [Patch #102915] xreadlines : readlines :: xrange : range

Tim Peters tim.one@home.com
Wed, 10 Jan 2001 13:49:40 -0500


[Tim]
> The strangest thing left to my eye is why xreadlines enjoys a
> significant advantage over the double-loop buffering method
> (readlines_sizehint) on my box; reducing the very large
> (1Mb) buffer in Guido's test program made no material difference
> to that.

[Guido]
> I was baffled at this too (same difference on my box), until I
> discovered that the buffer size is specified *twice*: once as a
> default in the arg list of readlines_sizehint(), then *again* in
> the call to timer() near the bottom of the file.

Bingo!

> Take the latter one out and the times are comparable, in fact
> readlines_sizehint() is a few percent quicker.

They're indistinguishable then on my box (on one run xreadlines is .1
seconds  (out of around 7.6 total) quicker, on another readlines_sizehint),
*provided* that I specify the same buffer size (8192) that xreadlines uses
internally.  However, if I even double that, readlines_sizehint is uniformly
about 10% slower.  It's also a tiny bit slower if I cut the sizehint buffer
size to 4096.

I'm afraid Mysteries will remain no matter how many person-decades we spend
staring at this <0.5 wink> ...