[issue27605] Inconsistent calls to __eq__ from built-in __contains__

R. David Murray report at bugs.python.org
Sun Jul 24 10:42:30 EDT 2016


R. David Murray added the comment:

I did look at the code.  Indeed list and tuple compare x to e, while dict, set, and frozenset (well, I didn't check each one, just list and set) compare the e to x, where e is they key stored at hash(x).

Steve has a good point about the iteration.  And a user class can do anything it wants in contains.  I wonder if it would be even more accurate to say "conceptually equal" rather than "approximately equal", given that hash table 'in' doesn't do iteration at all.

----------
nosy: +r.david.murray

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue27605>
_______________________________________


More information about the Python-bugs-list mailing list