Speed of Python vs. Perl
Tim Peters
tim.one at home.com
Thu Jan 11 04:26:10 EST 2001
[Michael P. Soulier]
>> [msoulier at lupus test]$ time ./bench.pl
>>
>> real 0m2.006s
>> user 0m1.950s
>> sys 0m0.030s
>>
>> [msoulier at lupus test]$ time ./bench.py
>>
>> real 0m0.558s
>> user 0m0.440s
>> sys 0m0.050s
[Tim Hammerquist]
> How much of these times is the startup time for the interpreters?
> Python has a profiler, and the Standard Perl Dist. includes the
> Benchmark module for this purpose. This would give you a more accurate
> picture of where the processor spends its time.
Python generally suffers much larger startup time than Perl. Indeed, on my
box, I can clearly see the difference between:
python -c "print 'hi'"
and
perl -e "print 'hi'"
by eyeball (the former takes a noticeable fraction of a second; the latter
appears instantaneous). The reasons for Python's relative startup sloth
have been discussed here often; a big one is that Python runs around looking
for Python files (like site.py and sitecustomize.py) at startup, and
typically does a big pile of failing fstats while failing to find those
files along the PYTHONPATH.
Despite that, Python is typically faster overall for me than is Perl. Then
again, the things I typically do may not be typical ...
has-trouble-spelling-"web"-let-along-programming-it-ly y'rs - tim
More information about the Python-list
mailing list