Raymond Hettinger added the comment: > when doing an operation that does linear search through a container, > the interpreter checks all items one by one, first checking identity > and then equality.
This is the guaranteed behavior. Changing it would result in subtle change in semantics (i.e. an equality match early in a sequence would be bypassed in favor of a later identity match). The current behavior also has favorable cache characteristics (i.e. each element is accessed exactly once) which provide benefits for long lists that cannot fit in L1 or L2 cache. That said, I feel your pain. Slow __eq__ tests are the bane of linear search. I recommend using a hashed container for fast searching or that you use a tool like PyPy that gives significant speed-ups. ---------- resolution: -> rejected status: open -> closed versions: -Python 3.1, Python 3.2, Python 3.3, Python 3.4 _______________________________________ 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