title: Numpy: efficient way to generate combinations from given ranges
body: <p>I have a n-dimension array as shown below:</p>
  
  <pre><code>np.array([[0,3],[0,3],[0,10]])
  </code></pre>
  
  <p>In this array, the elements denote the low and high values. Ex: <code>[0,3]</code> refers to <code>[0,1,2,3]</code></p>
  
  <p>I need to generate a combination of all values using the ranges given as above.
  For example, I want <code>[0,0,0], [0,0,1] ... [0,1,0] ... [3,3,10]</code></p>
  
  <p>I have tried the following to get what I want:</p>
  
  <pre><code>ds = np.array([[0,3],[0,3],[0,10]])
  nItems = int(reduce(lambda a,b: a * (b[1] - b[0] + 1), ds, 1))
  myCombinations = np.zeros((nItems,))
  nArrays = []
  for x in range(ds.shape[0]):
      low = ds[x][0]
      high= ds[x][1]
      nitm = high - low + 1
      ar = [x+low for x in range(nitm) ]
      nArrays.append(ar)
  
  myCombinations = cartesian(nArrays)
  </code></pre>
  
  <p>The cartesian function was taken from <a href="https://stackoverflow.com/questions/1208118/using-numpy-to-build-an-array-of-all-combinations-of-two-arrays">Using numpy to build an array of all combinations of two arrays</a></p>
  
  <p>I need to do this <strong>few million times</strong>.</p>
  
  <p>My question: is there <em>any better / efficient</em> way to do this? </p>