This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author wolma
Recipients oscarbenjamin, skrah, steven.daprano, wolma
Date 2014-02-08.22:59:50
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1391900391.25.0.427197838622.issue20499@psf.upfronthosting.co.za>
In-reply-to
Content
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.
History
Date User Action Args
2014-02-08 22:59:51wolmasetrecipients: + wolma, steven.daprano, skrah, oscarbenjamin
2014-02-08 22:59:51wolmasetmessageid: <1391900391.25.0.427197838622.issue20499@psf.upfronthosting.co.za>
2014-02-08 22:59:51wolmalinkissue20499 messages
2014-02-08 22:59:50wolmacreate