152 is faster that 221 ? I think not ...

Neil Schemenauer nas at python.ca
Tue Aug 28 09:42:06 EDT 2001


Dave Harrison wrote:
> Im writing a script that goes through and reads zipped log.  So far so
> cool.
[...]
> But to my surprise and mild horror 1.5.2 was clocking horrendously
> faster than 2.2.1 ....
> 
> Whats the deal?

The readlines() method of the gzip object is much slower in 2.x.
Internally it now just calls readline() repeat repeat repeat repeat
repeat repeat repeat repeatedly.  Using xreadlines() will not help since
it ends up calling readline() as well.  I don't know why the gzip module
was changed in this way but I'm sure it can be made much faster.  Anyone
what to submit a patch to SourceForge?

In the mean time you could use:

     file = os.popen("gzip -dc filename")

  Neil




More information about the Python-list mailing list