loop in python

Rick Wotnaz desparn at wtf.com
Mon Aug 22 10:29:31 EDT 2005


km <km at mrna.tn.nic.in> wrote in
news:mailman.3360.1124720412.10512.python-list at python.org: 

> Hi all,
> 
> Why is it that the implementation of empty loop so slow in
> python when compared to perl ? 
> 
> #i did this in python (v 1.5)
> for x in xrange(1000):
>     print x
> # this took 0.017 seconds 
> --------------------------
> #similar code in perl (v 5.6): 
> for $x (0..1000)
> {
> print $x;
> }
> # this took 0.005 seconds only  !!!
> 
> Is python runtime slow at all aspects when compared to perl ? 
> I really wonder what makes python slower than perl ? 
> Is there any proposal to make python faster in future versions ?
> 
> curious to know all these ...
> 

It appears that Python is not optimized for empty loops.

-- 
rzed



More information about the Python-list mailing list