From: Raymond Hettinger Date: Thu, 4 Dec 2003 20:04:09 +0000 (+0000) Subject: SF bug #849662. Dramatically, improve comparison speed for "if shl == None". X-Git-Tag: v2.4a1~1151 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=f477c884509ad5e6a4d2ef583dae9eb1cd6d125d;p=thirdparty%2FPython%2Fcpython.git SF bug #849662. Dramatically, improve comparison speed for "if shl == None". --- diff --git a/Lib/UserDict.py b/Lib/UserDict.py index 6b5c9dade6ac..35f86fc4dc10 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)