[issue5397] PEP 372: OrderedDict

Armin Ronacher report at bugs.python.org
Mon Mar 2 22:41:12 CET 2009


Armin Ronacher <armin.ronacher at active-4.com> added the comment:

Maybe premature optimization but maybe it would make sense to implement
__eq__ like this:

def __eq__(self, other):
    if isinstance(other, OrderedDict):
        if not dict.__eq__(self, other):
            return False
        return all(p == q for p, q in _zip_longest(self.items(),
                                                   other.items()))
    return dict.__eq__(self, other)

For the most likely case (that dicts are different) this should give a
speedup.

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


More information about the Python-bugs-list mailing list