Is `scipy.misc.comb` faster than an ad-hoc binomial computation?
Referring to the source code of scipy.misc.comb, the update routine of the result is:
val = 1 for j in xrange(min(k, N-k)): val = (val*(N-j))//(j+1) return val
whereas the update routine you suggested is:
ntok = 1 ktok = 1 for t in xrange(1, min(k, n - k) + 1): ntok *= n ktok *= t n -= 1 return ntok // ktok
My guess of the reason why SciPy's implementation is slower is due to the fact that the subroutine involves an integer division at each iteration while yours only calls division once at the return statement.