Speed of Python vs. Perl

Steve Holden sholden at holdenweb.com
Thu Jan 11 07:42:34 EST 2001


"Tim Peters" <tim.one at home.com> wrote in message
news:mailman.979205181.25734.python-list at python.org...
> [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
>

Would it be worth putting an optimization in so that the required paths,
etc., were pre-computed (for those who had specifically asked for such a
step)?

I can see the kinds of trouble this would lead to (same as needing to
"rehash" in some shells when new code was added to existring paths), but I
don't have any feel for how much of the startup overhead could be
precomputed.

and-don't-do-it-if-it-stops-you-from-implementing-nested-scopes-ly y'rs  -
steve





More information about the Python-list mailing list