Message241337
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. |
|
Date |
User |
Action |
Args |
2015-04-17 15:04:40 | ethan.furman | set | recipients:
+ ethan.furman, georg.brandl, ezio.melotti, eric.araujo, docs@python, jonrsharpe |
2015-04-17 15:04:40 | ethan.furman | set | messageid: <1429283080.62.0.4450895858.issue23987@psf.upfronthosting.co.za> |
2015-04-17 15:04:40 | ethan.furman | link | issue23987 messages |
2015-04-17 15:04:40 | ethan.furman | create | |
|