Raymond Hettinger
9ec7bc36fe
More design notes
2008-01-25 01:46:33 +00:00
Raymond Hettinger
9c6d81f5dd
Fix-up signature for approximation.
2008-01-25 01:23:38 +00:00
Raymond Hettinger
7ea82253ea
Add one other review comment.
2008-01-25 01:13:12 +00:00
Raymond Hettinger
921cb5d3a3
Mark todos and review comments.
2008-01-25 00:33:45 +00:00
Raymond Hettinger
a6216749fb
Add support for copy, deepcopy, and pickle.
2008-01-25 00:21:54 +00:00
Raymond Hettinger
909e334e8a
More code cleanup. Remove unnecessary indirection to useless class methods.
2008-01-24 23:50:26 +00:00
Raymond Hettinger
5b0e27e50d
Add support for int(r) just like the other numeric classes.
2008-01-24 19:30:19 +00:00
Raymond Hettinger
7a6eacd2ca
Clean-up and speed-up code by accessing numerator/denominator directly. There's no reason to enforce readonliness
2008-01-24 18:05:54 +00:00
Raymond Hettinger
f336c8b7e9
Cleanup
2008-01-24 02:05:06 +00:00
Raymond Hettinger
eb461904eb
Minor clean-up and more tests.
2008-01-24 02:00:25 +00:00
Raymond Hettinger
cf10926088
Add first-cut at an approximation function (still needs rounding tweaks). Add continued fraction conversions.
2008-01-24 00:54:21 +00:00
Jeffrey Yasskin
45169fbc80
Several tweaks: add construction from strings and .from_decimal(), change
...
__init__ to __new__ to enforce immutability, and remove "rational." from repr
and the parens from str.
2008-01-19 09:56:06 +00:00
Jeffrey Yasskin
d7b00334f3
Add rational.Rational as an implementation of numbers.Rational with infinite
...
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.
2008-01-15 07:46:24 +00:00