Author: Armin Rigo <[email protected]>
Branch:
Changeset: r67157:d7d63baf7ea4
Date: 2013-10-05 12:31 +0200
http://bitbucket.org/pypy/pypy/changeset/d7d63baf7ea4/
Log: (austiine, arigo)
issue1618: this should fix the performance degradation of 'pow(huge,
smallish, smallish)'. Note that CPython could use the same too.
diff --git a/rpython/rlib/rbigint.py b/rpython/rlib/rbigint.py
--- a/rpython/rlib/rbigint.py
+++ b/rpython/rlib/rbigint.py
@@ -734,7 +734,9 @@
# if base < 0:
# base = base % modulus
# Having the base positive just makes things easier.
- if a.sign < 0:
+ # As a (very good) optimization, we also reduce 'base' here
+ # if it is much bigger than the modulus.
+ if a.sign < 0 or a.numdigits() > c.numdigits():
a = a.mod(c)
elif b.sign == 0:
_______________________________________________
pypy-commit mailing list
[email protected]
https://mail.python.org/mailman/listinfo/pypy-commit