[issue27605] Inconsistent calls to __eq__ from built-in __contains__
Terry J. Reedy
report at bugs.python.org
Fri Jul 29 13:56:25 EDT 2016
Terry J. Reedy added the comment:
Here is a more accurate 'equivalent': "any(x is e or <one of x==e or e==x> for e in <candidate members of y>)" where 'candidate members' is "members with the same hash as x" for built-in hash-based collections and 'all members' for built-in unsorted sequences". I am sure that built-in range does a direct calculation. Instead of the above, I suggest this.
"For general collections, such as list, tuple, collections.deque, and most iterables, the expression `x in y` is usually equivalent to `any(x is e or x == e for e in y)`."
Hash-based collections should not be mentioned in such a sentence as the equivalency is completely wrong, as Steven noted.
----------
nosy: +terry.reedy
_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue27605>
_______________________________________
More information about the Python-bugs-list
mailing list