From cf341ed74bdb1dfc8d79391dcdd93a57c7af2f7d Mon Sep 17 00:00:00 2001 From: Jayant Dubey <271153438+themythofsisyphusjayant@users.noreply.github.com> Date: Mon, 16 Nov 2026 01:49:05 +0530 Subject: [PATCH] gh-158798: Replace misleading "hashable collections" in object.__hash__ docs --- Doc/reference/datamodel.rst | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/Doc/reference/datamodel.rst b/Doc/reference/datamodel.rst index 02663ed465f424e..18636f1adef5180 100644 --- a/Doc/reference/datamodel.rst +++ b/Doc/reference/datamodel.rst @@ -2258,11 +2258,12 @@ Basic customization If a class does not define an :meth:`__eq__` method it should not define a :meth:`__hash__` operation either; if it defines :meth:`__eq__` but not - :meth:`__hash__`, its instances will not be usable as items in hashable - collections. If a class defines mutable objects and implements an - :meth:`__eq__` method, it should not implement :meth:`__hash__`, since the - implementation of :term:`hashable` collections requires that a key's hash value is - immutable (if the object's hash value changes, it will be in the wrong hash + :meth:`__hash__`, its instances will not be usable as items in collections + of :term:`hashable` objects. If a class defines mutable objects and + implements an :meth:`__eq__` method, it should not implement + :meth:`__hash__`, since the implementation of collections of + :term:`hashable` objects requires that a key's hash value is immutable + (if the object's hash value changes, it will be in the wrong hash bucket). User-defined classes have :meth:`__eq__` and :meth:`__hash__` methods