[issue21234] __contains__ and friends should check "is" for all elements first

Wolfgang Maier report at bugs.python.org
Wed Apr 16 15:26:08 CEST 2014


Wolfgang Maier added the comment:

> l=[myObj() for x in range(10000)]
> 
> now compare:
> 
> >>> 1 in m # slowed down by myObj.__eq__
> False
> 
> >>> any(e is 1 for e in m) # identity checks only
> False

oops, sorry for the inconsistency here.

the first line should read:

m = [myObj() for x in range(10000)]

for this to work, of course.

----------

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


More information about the Python-bugs-list mailing list