• Jeffrey Yasskin's avatar
    Add rational.Rational as an implementation of numbers.Rational with infinite · d7b00334
    Jeffrey Yasskin yazdı
    precision. This has been discussed at http://bugs.python.org/issue1682. It's
    useful primarily for teaching, but it also demonstrates how to implement a
    member of the numeric tower, including fallbacks for mixed-mode arithmetic.
    
    I expect to write a couple more patches in this area:
     * Rational.from_decimal()
     * Rational.trim/approximate() (maybe with different names)
     * Maybe remove the parentheses from Rational.__str__()
     * Maybe rename one of the Rational classes
     * Maybe make Rational('3/2') work.
    d7b00334
numbers.py 9.98 KB