]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
[3.15] gh-152359: Update numbers.rst to reference numeric-hash docs (GH-152549) ...
authorMiss Islington (bot) <31488909+miss-islington@users.noreply.github.com>
Mon, 29 Jun 2026 10:04:51 +0000 (12:04 +0200)
committerGitHub <noreply@github.com>
Mon, 29 Jun 2026 10:04:51 +0000 (10:04 +0000)
gh-152359: Update numbers.rst to reference numeric-hash docs (GH-152549)
(cherry picked from commit 8ec36f14a552136d54072e3e5bb595ec1f4f0b5f)

Co-authored-by: Paper Moon <tangyuan0821@email.cn>
Co-authored-by: Bénédikt Tran <10796600+picnixz@users.noreply.github.com>
Doc/library/numbers.rst

index 57b35017072c97eabcda93633f2a44cf9d31884f..0ed24b4e6c5225dae2a54171a7c3357526473057 100644 (file)
@@ -90,20 +90,7 @@ Notes for type implementers
 
 Implementers should be careful to make equal numbers equal and hash
 them to the same values. This may be subtle if there are two different
-extensions of the real numbers. For example, :class:`fractions.Fraction`
-implements :func:`hash` as follows::
-
-    def __hash__(self):
-        if self.denominator == 1:
-            # Get integers right.
-            return hash(self.numerator)
-        # Expensive check, but definitely correct.
-        if self == float(self):
-            return hash(float(self))
-        else:
-            # Use tuple's hash to avoid a high collision rate on
-            # simple fractions.
-            return hash((self.numerator, self.denominator))
+extensions of the real numbers. See also :ref:`numeric-hash`.
 
 
 Adding More Numeric ABCs