Skip to content

Commit 8ec36f1

Browse files
gh-152359: Update numbers.rst to reference numeric-hash docs (#152549)
Co-authored-by: Bénédikt Tran <10796600+picnixz@users.noreply.github.com>
1 parent 8458582 commit 8ec36f1

1 file changed

Lines changed: 1 addition & 14 deletions

File tree

Doc/library/numbers.rst

Lines changed: 1 addition & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -90,20 +90,7 @@ Notes for type implementers
9090

9191
Implementers should be careful to make equal numbers equal and hash
9292
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))
93+
extensions of the real numbers. See also :ref:`numeric-hash`.
10794

10895

10996
Adding More Numeric ABCs

0 commit comments

Comments
 (0)