Jeffrey Yasskin
339f5e3ffc
Change simple instances (in Fraction) of self.numerator and self.denominator to
...
self._numerator and self._denominator. This speeds abs() up from 12.2us to
10.8us and trunc() from 2.07us to 1.11us. This doesn't change _add and friends
because they're more complicated.
2008-02-14 07:49:25 +00:00
Jeffrey Yasskin
1c214d6c94
Performance optimizations on Fraction's constructor.
...
./python.exe -m timeit -s 'from fractions import Fraction' 'Fraction(3)`
31.7 usec/loop -> 9.2 usec/loop
./python.exe -m timeit -s 'from fractions import Fraction' 'Fraction(3, 2)'`
27.7 usec/loop -> 9.32 usec/loop
./python.exe -m timeit -s 'from fractions import Fraction; f = Fraction(3, 2)' 'Fraction(f)'
31.9 usec/loop -> 14.3 usec/loop
2008-02-14 06:12:24 +00:00
Mark Dickinson
0aa52a1658
Revert change in r60712: turn alternate constructors back into
...
classmethods instead of staticmethods.
2008-02-12 21:40:53 +00:00
Mark Dickinson
e1b824793a
Implementation of Fraction.limit_denominator.
...
Remove Fraction.to_continued_fraction and
Fraction.from_continued_fraction
2008-02-12 21:31:59 +00:00
Mark Dickinson
cd873fc142
Put an extra space into the repr of a Fraction:
...
Fraction(1, 2) instead of Fraction(1,2).
2008-02-11 03:11:55 +00:00
Mark Dickinson
d058cd2cc8
Rename rational.Rational to fractions.Fraction, to avoid name clash
...
with numbers.Rational. See issue #1682 for related discussion.
2008-02-10 21:29:51 +00:00