[Tutor] Python Advocacy

rob@jam.rr.com rob@jam.rr.com
Sat, 14 Apr 2001 17:06:59 -0500


I've just composed two scripts that count from 2 to 10,000. One is in
Perl, freshly downloaded from ActiveState, and the other in Python 2.0.
Each ran in just about exactly 5 seconds from the command prompt on a
Win98 PII-266. Here are the scripts:

Python:

i = 0
while i <= 10000:
    i = i+1
    print i 


Perl:

$i = 0;
while ($i <= 10000){
	$i = $i + 1;
	print "$i\n";
	}

If anyone feels like an adventure (and knows how to do it), we could
devise a number of fair challenges for a Script Olympics of sorts. I've
only seen limited and somewhat dated comparisons between languages out
there as a general rule, so I'm tempted to come up with a few similar
scripts like this and put them head-to-head. (Kinda like *Junkyard
Wars*, only digital. 3;-> )

Uselessly yours,
Rob

Sheila King wrote:
> 
> On Fri, 13 Apr 2001 23:02:58 -0700 (PDT), Deirdre Saoirse
> <deirdre@deirdre.net>  wrote about Re: [Tutor] Python Advocacy:
> 
> :However, python is byte compiled, which may offer speed
> :advantages. However, in general, if you're looking for speed, you wouldn't
> :be using perl either.
> 
> I've been sharing the comments I've received to this post (some were sent by
> private e-mail, some came from comp.lang.python).
> 
> In response to Deidre's remarks above, someone responded:
> 
> PK> How Python being compiled to bytecodes would give it a speed advantage
> over Perl, which is
> PK> also compiled to "bytecodes" which are then interpreted, is beyond me.
> 
> I just am not qualified to respond to these types of remarks. Is anyone here
> game?
> 
> He further states:
> 
> PK> Speed is often not a BIG issue: if a script in Perl takes 1 minute and in
> Python
> PK>it took 1 and a half minutes, that's really not going to be an issue most
> of the time. If a Perl
> PK> script that runs in 1 minute takes 20 minutes in Python, that may well be
> an issue: and it's a
> PK> possibility too. http://home.hiwaay.net/~gbacon/py-vs-pl.html (It's from
> 1995: I assume Python
> PK> has gotten considerably faster since then. The point is that it most
> certainly COULD be that
> PK> scale of difference, not that it IS.)
> 
> Then he proposes a challenge: Some task, where the Perl fans will write their
> idiomatic solution, and the Python fans (me? I don't know that there is anyone
> else there), will write their solution. And then they'll benchmark it.
> 
> --
> Sheila King
> http://www.thinkspot.net/sheila/
> http://www.k12groups.org/
> 
> _______________________________________________
> Tutor maillist  -  Tutor@python.org
> http://mail.python.org/mailman/listinfo/tutor

-- 

Useless Python!
If your Python is this useless, we need you.
http://www.lowerstandard.com/python/pythonsource.html