Mercurial > public > mercurial-scm > hg-stable
diff mercurial/localrepo.py @ 8527:f9a80054dd3c
use 'x is None' instead of 'x == None'
The built-in None object is a singleton and it is therefore safe to
compare memory addresses with is. It is also faster, how much depends
on the object being compared. For a simple type like str I get:
| s = "foo" | s = None
----------+-----------+----------
s == None | 0.25 usec | 0.21 usec
s is None | 0.17 usec | 0.17 usec
author | Martin Geisler <mg@lazybytes.net> |
---|---|
date | Wed, 20 May 2009 00:52:46 +0200 |
parents | 865e08a7d6b0 |
children | 810387f59696 |
line wrap: on
line diff
--- a/mercurial/localrepo.py Wed May 20 00:43:23 2009 +0200 +++ b/mercurial/localrepo.py Wed May 20 00:52:46 2009 +0200 @@ -107,7 +107,7 @@ return dirstate.dirstate(self.opener, self.ui, self.root) def __getitem__(self, changeid): - if changeid == None: + if changeid is None: return context.workingctx(self) return context.changectx(self, changeid) @@ -1209,7 +1209,7 @@ fetch = set() seen = set() seenbranch = set() - if base == None: + if base is None: base = {} if not heads: @@ -1341,7 +1341,7 @@ or ancestors of these heads, and return a second element which contains all remote heads which get new children. """ - if base == None: + if base is None: base = {} self.findincoming(remote, base, heads, force=force)