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

Guido van Rossum guido@python.org
Thu, 11 Jan 2001 10:08:48 -0500


> 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> ...

8192 happens to be the size of the stack-allocated buffer readlines()
uses, and also the stdio BUFSIZ parameter, on many systems.  Look for
SMALLCHUNK in fileobject.c.

Would it make sense to tie the two constants together more to tune
this optimally even when BUFSIZ is different?

--Guido van Rossum (home page: http://www.python.org/~guido/)