[issue45080] functools._HashedSeq implements __hash__ but not __eq__
Leopold Talirz
report at bugs.python.org
Thu Sep 2 04:32:43 EDT 2021
Leopold Talirz <leopold.talirz at epfl.ch> added the comment:
Thanks a lot for the clarification, I get it now (I think).
> 2. _HashedSeq is only used as a key in a dictionary. When you look up a key in dictionary, it compares hashes first. __eq__ is only called when hashes match.
I was looking at the docs [1] and [2] and didn't come across this.
For me, this explanation of how __hash__ and __eq__ are used in the LRU cache would have been helpful to read in [1], but of course there is a tradeoff in how long to make docstrings.
If it is already explained somewhere else in the docs, linking to that place from [1] could be useful.
[1] https://docs.python.org/3/library/functools.html#functools.lru_cache
[2] https://docs.python.org/3/reference/datamodel.html#object.__hash__
----------
resolution: -> not a bug
stage: -> resolved
status: open -> closed
_______________________________________
Python tracker <report at bugs.python.org>
<https://bugs.python.org/issue45080>
_______________________________________
More information about the Python-bugs-list
mailing list