Wolfgang Maier added the comment:
I worked out a slightly speedier version of decimal_to_ratio today (Stefan:
that's when I duplicated your bug report):
from decimal import Context
def _decimal_to_ratio (x):
_, digits, exp = x.as_tuple()
if exp in _ExactRatio.decimal_infinite: # INF, NAN, sNAN
assert not d.is_finite()
raise ValueError
if exp < 0:
exp = -exp
return int(x.scaleb(exp, Context(prec=len(digits)))), 10**exp
return int(x), 1
makes the variance functions in my re-implementation about 20-30% faster for
Decimal. It's not a big breakthrough, but still.
----------
_______________________________________
Python tracker <[email protected]>
<http://bugs.python.org/issue20499>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe:
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com