performance of Nested for loops

Charles Krug cdkrug at worldnet.att.net
Fri May 20 18:54:47 EDT 2005


On 20 May 2005 15:35:10 -0700, querypk at gmail.com <querypk at gmail.com>
wrote:
> Is there a better way to code nested for loops as far as performance is
> concerned.
> 
> what better way can we write to improve the speed.
> for example:
> N=10000
> for i in range(N):
>    for j in range(N):
>        do_job1
>    for j in range(N):
>        do_job2
> 

What do you see when you profile the code?  

Premature Optimization is the root of all manner of evil and all that
good stuff.




More information about the Python-list mailing list