loop in python

km km at mrna.tn.nic.in
Tue Aug 23 04:43:06 EDT 2005


Hi all,

ya i am sorry  i tried with an empty loop first and then one which emits a value as the snippet. I have tested it on my machine and now ... 

1) perl (v 5.8) does the job in 0.005 seconds
2) but python (v 2.4.1) is horribly slow its 0.61 seconds.
and using range() instead of xrange() in python snippet, it not better , it takes 0.57 seconds. just test it urself and see.

what more do i need to accept python is slow when it comes to loops concept ?

PS : my linux box is running fedora core 2 with 256 MB RAM

regards,
KM
-----------------------------------------------------------------------
On Tue, Aug 23, 2005 at 12:25:01PM +0530, km wrote:
> 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 ...
> 
> regards,
> KM
> 
> -- 
> http://mail.python.org/mailman/listinfo/python-list
> 




More information about the Python-list mailing list