Wolfgang Maier added the comment:

>> - if an object is in the container that is equal to the object, it will be 
>> slower, but not very much.

You don't know that in general. It depends on where in the sequence the equal 
object sits, and also on how expensive the equality check is compared to the 
identity check.

A simplified example over your rather lengthy one:

>>> l=list(range(20000000))
>>> any(e is 9000000 or e == 9000000 for e in l) # mimicking current behaviour
True
>>> any(e is 9000000 for e in l) or any(e == 9000000 for e in l) # your 
>>> suggestion
True

The second example takes about twice as long as the first one because the 
identity check has to be run on the whole list, when the equality check 
discovers the match half way through the sequence.
Given that equality is usually more likely than identity, I guess, you would 
pay a price for your suggestion more often than you profit from it.

----------
nosy: +wolma

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

Reply via email to