title: Parallelise nested for-loop in IPython
body: <p>I have a nested for loop in my python code that looks something like this:</p>
  
  <pre><code>results = []
  
  for azimuth in azimuths:
      for zenith in zeniths:
          # Do various bits of stuff
          # Eventually get a result
          results.append(result)
  </code></pre>
  
  <p>I'd like to parallelise this loop on my 4 core machine to speed it up. Looking at the IPython parallel programming documentation (http://ipython.org/ipython-doc/dev/parallel/parallel_multiengine.html#quick-and-easy-parallelism) it seems that there is an easy way to use <code>map</code> to parallelise iterative operations.</p>
  
  <p>However, to do that I need to have the code inside the loop as a function (which is easy to do), and then map across this function. The problem I have is that I can't get an array to map this function across. <code>itertools.product()</code> produces an iterator which I can't seem to use the map function with.</p>
  
  <p>Am I barking up the wrong tree by trying to use map here? Is there a better way to do it? Or is there some way to use <code>itertools.product</code> and then do parallel execution with a function mapped across the results?</p>