Numpy with Combinatoric generators: How does one speed up Combinations?
问题 It is my understanding that the itertools functions are written in C. If i wanted to speed this example code up: 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 Since combinations_with_replacement is written in C, does that imply that