Surprising (for me) benchmark results...

Don O'Donnell donod at home.com
Tue May 1 22:03:31 EDT 2001


"E. Mark Ping" wrote:

>     I inserted timing for the sort,
> and in Python (in the small case) it was about 180 ms, whereas in C++
> it was about 140 ms.

Most likely then it's in the file I/O that Python is beating out the
others.  What version of Python did you use.  the reason I ask is
because I read on the www.python.org site in A.K.'s "What's New in
Python 2.1":

"""
The speed of line-oriented file I/O has been improved because people
often complain about its lack of speed, and because it's often been used
as a naïve benchmark. The readline() method of file objects has
therefore been rewritten to be much faster. The exact amount of the
speedup will vary from platform to platform depending on how slow the C
library's getc() was, but is around 66%, and potentially much faster on
some particular operating systems. Tim Peters did much of the
benchmarking and coding for this change, motivated by a discussion in
comp.lang.python. 
"""

If a version earlier than 2.1 was used in these tests, it would be
interesting to see the results using the new and improved readline().

Hmm, I just noticed, the quote refers to readline() not readlines().  I
wonder if readlines() has also been speeded up.  Of course, you're
better off sticking with readlines() whether improved or not.

-Don



More information about the Python-list mailing list