Merged revisions 82646,82649-82650 via svnmerge from

svn+ssh://pythondev@svn.python.org/python/branches/py3k

........
  r82646 | mark.dickinson | 2010-07-08 18:23:40 +0100 (Thu, 08 Jul 2010) | 1 line

  In test_decimal, convert heuristic for skipping tests into an explicit skiplist.
........
  r82649 | mark.dickinson | 2010-07-08 20:03:34 +0100 (Thu, 08 Jul 2010) | 1 line

  Fix a performance issue in Decimal.pow.  Thanks Stefan Krah for finding this.
........
  r82650 | mark.dickinson | 2010-07-08 20:09:16 +0100 (Thu, 08 Jul 2010) | 1 line

  Fix misplaced exactness check that was causing unnecessary work in Decimal.__pow__.
........
This commit is contained in:
Mark Dickinson 2010-07-08 19:24:40 +00:00
parent 22db73523c
commit e85aa739ab
4 changed files with 64 additions and 50 deletions

View file

@ -1990,12 +1990,14 @@ class Decimal(object):
# case where xc == 1: result is 10**(xe*y), with xe*y
# required to be an integer
if xc == 1:
if ye >= 0:
exponent = xe*yc*10**ye
else:
exponent, remainder = divmod(xe*yc, 10**-ye)
if remainder:
return None
xe *= yc
# result is now 10**(xe * 10**ye); xe * 10**ye must be integral
while xe % 10 == 0:
xe //= 10
ye += 1
if ye < 0:
return None
exponent = xe * 10**ye
if y.sign == 1:
exponent = -exponent
# if other is a nonnegative integer, use ideal exponent
@ -2268,9 +2270,10 @@ class Decimal(object):
# try for an exact result with precision +1
if ans is None:
ans = self._power_exact(other, context.prec + 1)
if ans is not None and result_sign == 1:
ans = _dec_from_triple(1, ans._int, ans._exp)
exact = True
if ans is not None:
if result_sign == 1:
ans = _dec_from_triple(1, ans._int, ans._exp)
exact = True
# usual case: inexact result, x**y computed directly as exp(y*log(x))
if ans is None: