Re: performance of Nested for loops

2005-05-20 Thread Charles Krug
On 20 May 2005 15:35:10 -0700, [EMAIL PROTECTED] [EMAIL PROTECTED] 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=1 for i in range(N): for j in range(N): do_job1

Re: performance of Nested for loops

2005-05-20 Thread Larry Bates
You can use xrange(N) that way Python doesn't have to build the 1 item lists 2 times. Other than that one would need to know why you would call do_job1 and do_job2 1 times each inside a 1 iteration loop. Most VERY large performance gains are due to better algorithms not code

Re: performance of Nested for loops

2005-05-20 Thread Andrew Dalke
querypk 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=1 for i in range(N): for j in range(N): do_job1 for j in range(N): do_job2 For this case compute