We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 5f5dbfb commit 395e117Copy full SHA for 395e117
1 file changed
Doc/library/numbers.rst
@@ -90,20 +90,7 @@ Notes for type implementers
90
91
Implementers should be careful to make equal numbers equal and hash
92
them to the same values. This may be subtle if there are two different
93
-extensions of the real numbers. For example, :class:`fractions.Fraction`
94
-implements :func:`hash` as follows::
95
-
96
- def __hash__(self):
97
- if self.denominator == 1:
98
- # Get integers right.
99
- return hash(self.numerator)
100
- # Expensive check, but definitely correct.
101
- if self == float(self):
102
- return hash(float(self))
103
- else:
104
- # Use tuple's hash to avoid a high collision rate on
105
- # simple fractions.
106
- return hash((self.numerator, self.denominator))
+extensions of the real numbers. See also :ref:`numeric-hash`.
107
108
109
Adding More Numeric ABCs
0 commit comments