From f477c884509ad5e6a4d2ef583dae9eb1cd6d125d Mon Sep 17 00:00:00 2001 From: Raymond Hettinger Date: Thu, 4 Dec 2003 20:04:09 +0000 Subject: SF bug #849662. Dramatically, improve comparison speed for "if shl == None". --- Lib/UserDict.py | 2 ++ 1 file changed, 2 insertions(+) (limited to 'Lib/UserDict.py') diff --git a/Lib/UserDict.py b/Lib/UserDict.py index 6b5c9dade6..35f86fc4dc 100644 --- a/Lib/UserDict.py +++ b/Lib/UserDict.py @@ -155,6 +155,8 @@ class DictMixin: def __repr__(self): return repr(dict(self.iteritems())) def __cmp__(self, other): + if other is None: + return 1 if isinstance(other, DictMixin): other = dict(other.iteritems()) return cmp(dict(self.iteritems()), other) -- cgit v1.2.1