[issue1682] Move Demo/classes/Rat.py to Lib/fractions.py and fix it up.
report at bugs.python.org
Mon Feb 18 23:51:06 CET 2008
Jeffrey Yasskin added the comment:
1) No worries. Even without inlining the common case of __add__, etc.,
Fraction is now faster than Decimal for smallish fractions
[sum(Fraction(1, i) for i in range(1, 100))], and for large ones
[sum(Fraction(1, i) for i in range(1, 1000))] gcd takes so much of the
time that I can't see the effects of any of the optimizations I've made.
Since I wasn't thinking of this as a high-performance class, I'm taking
that as a sign to stop optimizing, but gcd is definitely the function to
tackle if anyone wants to keep going.
2) I haven't been following __format__, but adding it to Rational sounds
fine to me.
Tracker <report at bugs.python.org>
More information about the Python-bugs-list