[issue30907] speed up comparisons to self for built-in containers

Tim Peters report at bugs.python.org
Fri Jul 21 12:14:24 EDT 2017


Tim Peters added the comment:

Victor, this part of the docs explains what you're seeing; scroll down to the

"""
In enforcing reflexivity of elements, the comparison of collections assumes that for a collection element x, x == x is always true ...
"""

part.

https://docs.python.org/3/reference/expressions.html#value-comparisons

In passing, note that dicts indexed by strings (well, indexed by anything) _do_ compare hashes first.  In that specific case it's a major win - but in that specific case we also know in advance that "EQ or NE?" is the only question needing an answer.

----------

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


More information about the Python-bugs-list mailing list