Newsgroups: gnu.misc.discuss,comp.lang.tcl,comp.lang.scheme,comp.lang.python
Path: cantaloupe.srv.cs.cmu.edu!das-news.harvard.edu!news2.near.net!MathWorks.Com!yeshua.marcam.com!usc!howland.reston.ans.net!EU.net!sun4nl!cwi.nl!guido
From: guido@cwi.nl (Guido van Rossum)
Subject: Re: Tcl/Lisp/Python: A "User" point of view
Message-ID: <Cww0DA.I68@cwi.nl>
Sender: news@cwi.nl (The Daily Dross)
Nntp-Posting-Host: voorn.cwi.nl
Organization: CWI, Amsterdam
References: <9409232314.AA29957@mole.gnu.ai.mit.edu> <SCHWARTZ.94Sep24164719@groucho.cse.psu.edu> <KFOGEL.94Sep24225539@ninja.life.uiuc.edu> <1994Sep27.085636.23932@paramount.nikhefk.nikhef.nl> <36cafa$5ue@btree.brooktree.com>
Date: Thu, 29 Sep 1994 10:41:33 GMT
Lines: 64
Xref: glinda.oz.cs.cmu.edu gnu.misc.discuss:18538 comp.lang.tcl:19619 comp.lang.scheme:10107 comp.lang.python:1764

mdimeo@brooktree.com (Matt DiMeo) writes:
>The users will care about O(1) vs. O(n) as soon as they notice how long it
>takes for tcl to build up a ten thousand element list.

>tst.tcl------------------
>set l ""
>for { set i 0 } { $i < 10000 } { incr i } {
>    lvarpush l $i
>}
>-------------------------

>tst.perl-----------------
>for ($i = 0 ; $i < 10000 ; $i++) {
>    unshift(@f, $i) ;
>}
>-------------------------

>{/home/mdimeo}% /bin/time /cad/bin/perl tst.perl
>	4.8 real         4.6 user         0.0 sys  
>{/home/mdimeo}% /bin/time tcl tst.tcl
>^CCommand terminated abnormally.
>      334.2 real       326.7 user         0.2 sys  

Since this was cross-posted to comnp.lang.python, here are the results
of comparing Perl and Python.  I print the Perl numbers too since the
CPU was unspecified.

	& 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!  I'm sure that there
are lots of things that Perl does faster -- and lots of things where
Python wins.  They are meant for different purposes.

--Guido van Rossum, CWI, Amsterdam <mailto:Guido.van.Rossum@cwi.nl>
<http://www.cwi.nl/cwi/people/Guido.van.Rossum.html>
