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

2019-05-30 Thread Cheryl Sabella
Change by Cheryl Sabella : -- assignee: -> docs@python components: +Documentation nosy: +docs@python stage: -> needs patch versions: +Python 3.8, Python 3.9 ___ Python tracker

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

2016-07-29 Thread Terry J. Reedy
Terry J. Reedy added the comment: Here is a more accurate 'equivalent': "any(x is e or for e in )" 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

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

2016-07-24 Thread Raymond Hettinger
Raymond Hettinger added the comment: +1 for "approximately equivalent". The "conceptually equivalent" wording raises more questions in my mind than it answers. What we're really trying to say here is that for typically symmetric operations such as __eq__(), an implementation is free to

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

2016-07-24 Thread R. David Murray
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

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

2016-07-24 Thread Serhiy Storchaka
Changes by Serhiy Storchaka : -- nosy: +rhettinger ___ Python tracker ___ ___

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

2016-07-24 Thread Steven D'Aprano
Steven D'Aprano added the comment: I'm reluctant to call this a behaviour bug, because I'm reluctant to guarantee the *precise* behaviour when the classes are different. I haven't checked the source of dict.__contains__, but by experimentation it seems that: needle in {key: value} calls

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

2016-07-24 Thread Vasiliy Faronov
New submission from Vasiliy Faronov: Consider the attached example program. I expect it to run successfully, because the Python 3 language reference says [1]: > For container types such as list, tuple, set, frozenset, dict, or > collections.deque, the expression `x in y` is equivalent to