On Sat, Oct 8, 2016 at 8:58 PM, meInvent bbird <jobmatt...@gmail.com> wrote: > how to refactor nested for loop into smaller for loop assume each of them > independent? > > because memory is not enough > > for ii in range(1,2000): > for jj in range(1,2000): > for kk in range(1,2000): > print run(ii,jj,kk)
Since you're using Python 2, you could try xrange instead of range. But it won't make a lot of difference. You're trying to call your run function 8,000,000,000 times... that is a *lot* of function calls. Consider a faster algorithm instead! ChrisA -- https://mail.python.org/mailman/listinfo/python-list