title: Numpy with Combinatoric generators: How does one speed up Combinations?
body: <p>It is my understanding that the <a href="http://docs.python.org/2/library/itertools.html" rel="nofollow">itertools functions</a> <a href="http://blog.behnel.de/index.php?p=163" rel="nofollow">are written in C</a>. If i wanted to speed this example code up:</p>
  
  <pre><code>import numpy as np
  from itertools import combinations_with_replacement
  
  def combinatorics(LargeArray):
       newArray = np.empty((LargeArray.shape[0],LargeArray.shape[0]))
       for x, y in combinations_with_replacement(xrange(LargeArray.shape[0]), r=2):
           z = LargeArray[x] + LargeArray[y]
           newArray[x, y] = z
       return newArray
  </code></pre>
  
  <p>Since <code>combinations_with_replacement</code> is written in C, does that imply that it can't be sped up? Please advise.</p>
  
  <p>Thanks in advance.</p>