[issue37295] Possible optimizations for math.comb()

Raymond Hettinger report at bugs.python.org
Tue Jan 11 18:04:09 EST 2022


Raymond Hettinger <raymond.hettinger at gmail.com> added the comment:

One fixup:

-     j = min(k // 2, FixedJ) 
+     j = FixedJ if k > FixedJ else k // 2 

With that fix, the number of 64-bit mod arithmetic calls drops to 3, 4, and 20 for C(200,100), C(225,112), and C(250,125).  The compares to 115, 150, and 193 calls in the current code.

----------
Added file: https://bugs.python.org/file50556/comb_pole.py

_______________________________________
Python tracker <report at bugs.python.org>
<https://bugs.python.org/issue37295>
_______________________________________


More information about the Python-bugs-list mailing list