Re: Tcl/Lisp/Python: A "User" point of view

Andreas Koenig (koen1830@w250zrz.zrz.tu-berlin.de)
29 Sep 1994 17:29:18 GMT

In article <Cww0DA.I68@cwi.nl>, Guido van Rossum <guido@cwi.nl> wrote:
> & time perl tst.pl
>
> real 5.94
> user 5.74
> sys 0.09
>
> & time python tst.py
>
> real 1.35
> user 1.12
> sys 0.08
>
> & cat tst.py
> l = []
> for i in range(10000):
> l.append(i)
>
> & cat tst.pl
> for ($i = 0 ; $i < 10000 ; $i++) {
> unshift(@f, $i) ;
> }
>
> &
>
>Should I say more?
>
>One note on the Python program -- I could've cheated and simply used
> l = range(10000)
>but that would've moved the entire loop into C, while what's really at
>stake here is 10000 calls to the internal "append to list" call.
>
>BTW this is not a formal benchmark by any means!

Interesting, I don't know python, but `append' looks like you are
appending to an array, while in perl you unshift, which is quite a
different operation. If I replace the unshift with a push in the perl
script, the results on my slow NeXT are:

~> time perl tst.pl
1.609s real 1.406s user 0.203s system 100% perl tst.pl
~> time python tst.py
4.818s real 3.733s user 0.203s system 81% python tst.py
~>

--andreas koenig