summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRaymond Hettinger <python@rcn.com>2008-01-25 00:33:45 +0000
committerRaymond Hettinger <python@rcn.com>2008-01-25 00:33:45 +0000
commit921cb5d3a3e823c6c225681d8e99f7baa8920f3e (patch)
treed651e271796efcd1f7e2e47b7dc6a0115f3b8026
parenta6216749fb88fb508cd469839d77d4264a881bd4 (diff)
downloadcpython-git-921cb5d3a3e823c6c225681d8e99f7baa8920f3e.tar.gz
Mark todos and review comments.
-rwxr-xr-xLib/rational.py13
1 files changed, 13 insertions, 0 deletions
diff --git a/Lib/rational.py b/Lib/rational.py
index 031ee0f20e..90abe62d95 100755
--- a/Lib/rational.py
+++ b/Lib/rational.py
@@ -40,6 +40,8 @@ def _binary_float_to_ratio(x):
>>> _binary_float_to_ratio(-.25)
(-1, 4)
"""
+ # XXX Consider moving this to to floatobject.c
+ # with a name like float.as_intger_ratio()
if x == 0:
return 0, 1
@@ -219,6 +221,16 @@ class Rational(RationalAbc):
else:
return '%s/%s' % (self.numerator, self.denominator)
+ """ XXX This section needs a lot more commentary
+
+ * Explain the typical sequence of checks, calls, and fallbacks.
+ * Explain the subtle reasons why this logic was needed.
+ * It is not clear how common cases are handled (for example, how
+ does the ratio of two huge integers get converted to a float
+ without overflowing the long-->float conversion.
+
+ """
+
def _operator_fallbacks(monomorphic_operator, fallback_operator):
"""Generates forward and reverse operators given a purely-rational
operator and a function from the operator module.
@@ -419,6 +431,7 @@ class Rational(RationalAbc):
float must have the same hash as that float.
"""
+ # XXX since this method is expensive, consider caching the result
if self.denominator == 1:
# Get integers right.
return hash(self.numerator)