[pypy-commit] pypy math-improvements: Make inplace_divmod unsigned, this makes for a ~20% speed up in long / single digit
stian
pypy.commits at gmail.com
Sun Nov 12 02:41:43 EST 2017
Author: stian
Branch: math-improvements
Changeset: r92993:3c7a6c85f39c
Date: 2017-11-12 08:40 +0100
http://bitbucket.org/pypy/pypy/changeset/3c7a6c85f39c/
Log: Make inplace_divmod unsigned, this makes for a ~20% speed up in long
/ single digit
diff --git a/rpython/rlib/rbigint.py b/rpython/rlib/rbigint.py
--- a/rpython/rlib/rbigint.py
+++ b/rpython/rlib/rbigint.py
@@ -718,7 +718,7 @@
elif a._digits[0] == ONEDIGIT:
return rbigint(b._digits[:bsize], a.sign * b.sign, bsize)
elif bsize == 1:
- res = b.uwidedigit(0) * a.uwidedigit(0)
+ res = b.uwidedigit(0) * a.udigit(0)
carry = res >> SHIFT
if carry:
return rbigint([_store_digit(res & MASK), _store_digit(carry)], a.sign * b.sign, 2)
@@ -1949,13 +1949,13 @@
Divide bigint pin by non-zero digit n, storing quotient
in pout, and returning the remainder. It's OK for pin == pout on entry.
"""
- rem = _widen_digit(0)
+ rem = _unsigned_widen_digit(0)
assert n > 0 and n <= MASK
if not size:
size = pin.numdigits()
size -= 1
while size >= 0:
- rem = (rem << SHIFT) | pin.digit(size)
+ rem = (rem << SHIFT) | pin.udigit(size)
hi = rem // n
pout.setdigit(size, hi)
rem -= hi * n
More information about the pypy-commit
mailing list