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

STINNER Victor report at bugs.python.org
Fri Jul 21 12:02:02 EDT 2017


STINNER Victor added the comment:

I never understood how container comparison works.

>>> nan = float("nan")
>>> [nan] == [nan]
True
>>> (nan,) == (nan,)
True
>>> nan == nan
False
>>> nan is nan
True

I picked the float NaN because it's one of the weirdest object in Python: it's not equal to itself.

I don't know what is the impact of the proposed change on comparison. Can it break an application? It's unclear to me.

--

It also recalls me an optimization I proposed on string: begin with comparison on the hash, if the two hashs are already known. At the end, we decided that it wasn't worth it.

--

Raymond, Tim and Serhiy don't seem to be convince, so I will follow them and agree to reject this optimization :-)

----------

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


More information about the Python-bugs-list mailing list