Mercurial > public > mercurial-scm > hg
comparison mercurial/ui.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 | d728f126c1b7 |
children | 6419bc7b3d9c |
comparison
equal
deleted
inserted
replaced
8526:f78eadbb5769 | 8527:f9a80054dd3c |
---|---|
127 "%s.%s = %s\n") % (section, name, uvalue)) | 127 "%s.%s = %s\n") % (section, name, uvalue)) |
128 return value | 128 return value |
129 | 129 |
130 def configbool(self, section, name, default=False, untrusted=False): | 130 def configbool(self, section, name, default=False, untrusted=False): |
131 v = self.config(section, name, None, untrusted) | 131 v = self.config(section, name, None, untrusted) |
132 if v == None: | 132 if v is None: |
133 return default | 133 return default |
134 if v.lower() not in _booleans: | 134 if v.lower() not in _booleans: |
135 raise error.ConfigError(_("%s.%s not a boolean ('%s')") | 135 raise error.ConfigError(_("%s.%s not a boolean ('%s')") |
136 % (section, name, v)) | 136 % (section, name, v)) |
137 return _booleans[v.lower()] | 137 return _booleans[v.lower()] |