Hi, I am wondering if there is a way to efficiently run a double loop in Python. To be more precise, I would like to compute the sum of a function f(x,y) for every possible (x,y) pair.
I have tried several alternatives so far: 1) the classic double loop: for x in X: for y in Y: sum += f(x,y) 2) using list comprehension: sum([f(x,y) for x in X for y in Y]) 3) I figured out that the loop was slow, so I used map() to generate a list of every combination and then map to compute the result. But it is not very memory efficient and still pretty slow. I know I might try to use SciPy & co to do it but I would prefer to be able to run my script on any default python installation. Any suggestion ? Regards, -- Ben _______________________________________________ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor