loop in python

Terry Reedy tjreedy at udel.edu
Mon Aug 22 13:01:45 EDT 2005


"km" <km at mrna.tn.nic.in> wrote in message 
news:20050823084306.GA24951 at mrna.tn.nic.in...
> 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.

I did.  "for x in xrange(10000000): pass" (cut and pasted, Python 2.2, 10 
million passes) takes about 1.5 second (estimated by 'one thousand and 
one...' method).  Divide by 10000 for your 1000 iteration test.

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

Valid comparitive data from honest and competant testers with different but 
properly functioning systems.

Terry J. Reedy






More information about the Python-list mailing list