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=10000 > for i in range(N): > for j in range(N): > do_job1 > for j in range(N): > do_job2
For this case compute the range once range_10000 = range(10000) for i in range_10000: for j in range_10000: do_job1() for j in range_10000: do_job2() Using xrange(10000) may be faster but you would need to test that out for your case. Andrew [EMAIL PROTECTED] -- http://mail.python.org/mailman/listinfo/python-list