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

Raymond Hettinger report at bugs.python.org
Thu Jul 13 00:58:33 EDT 2017


Raymond Hettinger added the comment:

This seems like it optimizes an irrelevant use case, comparing a container to itself.  

I don't think this is likely to benefit any existing code, so it would be better not to add more code clutter/complexity with another special case code path unless we're pretty sure that special case actually arises in practice.

FWIW, the note about identity-implies-equality is a statement about how containers implement element comparison rather than about how two containers are compared to one another (as implemented in PyObject_RichCompareBool()).  Also, it isn't just an optimization, it is necessary to help us reason about containers (i.e. preserving the invariant: all(x in c for x in c)).

----------
type:  -> performance

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


More information about the Python-bugs-list mailing list