"in" for dicts (was: Python 2.1 function attributes)

Tim Peters tim.one at home.com
Mon Jan 29 18:23:59 EST 2001


[Terry Reedy]
> Comparers of Perl and Python constantly notice that Perl is (was?) faster
> in its equivalent of the new 'for l in f.xreadlines()'.

is/was varies by platform.  In general, though, Python's line-at-a-time file
input is threadsafe while Perl's isn't, and we still pay something for that;
we also haven't pulled the platform-dependent tricks Perl does to optimize
char-at-a-time reading the way vendors *should* optimize fgets() but almost
never do (Tru64 Unix appears to be the sole probable exception to date).  So
expect Perl to remain significantly faster for this on most boxes, but no
longer factors of 5-40 times faster.

> My first thought was 'hope this is enough faster to quiet some of
> the noise.
>
> Python won't be the first system to optimize a common 'benchmark'.

I couldn't care less about this in a benchmark context.  Real-life
file-munging applications generally aren't rocket science, and I/O time is
often the dominant part.  So it was real programs running scads slower that
I was concerned about -- speeding a very common operation isn't just
marketing fluff.

if-we-cared-about-benchmarks-we'd-make-fibonacci-a-builtin<wink>-ly
    y'rs  - tim





More information about the Python-list mailing list