152 is faster that 221 ? I think not ...
ignacio at openservices.net
Tue Aug 28 14:04:49 CEST 2001
On Tue, 28 Aug 2001, Ignacio Vazquez-Abrams wrote:
> It's quite simple. file.readlines() generates a true list in one go, whereas
> xreadlines.xreadlines() creates a generator that has to be called each time
> you want a line. Generators will never be faster than data.
> If you test range() versus xrange() for very large values you'll find the same
> thing, even in the same version of Python.
Okay, after doing some testing, I'm going to retract what I said about range
v. xrange (at least on my P2-266). It seems that they're too close to tell,
and sometimes xrange() does seem faster. I can'r entirely explain xreadlines()
without going into source.
One thing I _will_ say, however, is that 2.1.1 is faster then 1.5.2 with
respect to both range() and xrange().
Ignacio Vazquez-Abrams <ignacio at openservices.net>
More information about the Python-list