[issue37295] Possible optimizations for math.comb()

Tim Peters report at bugs.python.org
Thu Dec 30 12:59:53 EST 2021


Tim Peters <tim at python.org> added the comment:

> Aargh! That is of course what I meant, but not in fact
> what I timed. :-(

!!! Even more baffling then. Seems like the code posted got out of math_comb_impl() early here:

        if (overflow || ki > ni) {
            result = PyLong_FromLong(0);
            goto done;
        }

67 out of every 68 times comb() was called, before any actual ;-) computation was even tried. Yet one way was significantly faster than the other overall, despite that they were so rarely executed at all?

Something ... seems off here ;-)

----------

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


More information about the Python-bugs-list mailing list