[issue19171] pow() improvement on longs

Mark Dickinson report at bugs.python.org
Tue Oct 8 10:13:42 CEST 2013


Mark Dickinson added the comment:

> It would be crazy to not apply this little fix-up.

Crazy?  How so?

Note that this change, while introducing a performance enhancement in some rather unlikely corner cases, also introduces a performance regression in some other unlikely corner cases:

Before the patch (2.7):

iwasawa:cpython mdickinson$ ./python.exe -m timeit -s "a=7**10000; b=0; c=23" "pow(a, b, c)"
1000000 loops, best of 3: 0.232 usec per loop

After the patch:

iwasawa:cpython mdickinson$ ./python.exe -m timeit -s "a=7**10000; b=0; c=23" "pow(a, b, c)"
100000 loops, best of 3: 13.8 usec per loop

That can be easily fixed with more special-casing and more code, but I don't think this sort of experimentation is appropriate for a bugfix branch.

----------

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue19171>
_______________________________________


More information about the Python-bugs-list mailing list