Ethan Furman added the comment:

It's not quite that simple -- those containers use the hash to find the objects 
that will be first checked by identity, and then equality* -- otherwise they 
would have to do a complete scan from first key to last, and that would kill 
performance.

...

Okay, I see your point -- even for sane objects, a systematic check of every 
key is not undertaken for the hash-type containers.

Perhaps something like:

For container types such as list, tuple, or collections.deque, the expression 
'x in y' is equivalent to 'any(x is e or x == e for e in y)'.  For container 
types such as set, frozenset, and dict, 'x in y' is equivalent to 'any(x is e 
or x == e for e in z)' where 'z' is a collection of objects in 'y' that have 
the same hash.

----------

_______________________________________
Python tracker <rep...@bugs.python.org>
<http://bugs.python.org/issue23987>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to