summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlexandre Conrad <alexandre@surveymonkey.com>2011-12-03 22:42:15 -0800
committerAlexandre Conrad <alexandre@surveymonkey.com>2011-12-03 22:42:15 -0800
commit1c37b5487d229d1896ec983de1377f3282825739 (patch)
tree73b66a4e333292c9d046eaec20b42e232eebbdc0
parentd5666e630a08c943a22682540aa51174cee6851f (diff)
downloadpyramid-1c37b5487d229d1896ec983de1377f3282825739.tar.gz
pyramid-1c37b5487d229d1896ec983de1377f3282825739.tar.bz2
pyramid-1c37b5487d229d1896ec983de1377f3282825739.zip
minor item lookup speed improvement
-rw-r--r--pyramid/settings.py6
1 files changed, 4 insertions, 2 deletions
diff --git a/pyramid/settings.py b/pyramid/settings.py
index 11587a8be..86304307e 100644
--- a/pyramid/settings.py
+++ b/pyramid/settings.py
@@ -26,6 +26,8 @@ deprecated(
'the ``settings`` attribute of the registry available from the request '
'(``request.registry.settings``)).')
+truthy = frozenset(('t', 'true', 'y', 'yes', 'on', '1'))
+
def asbool(s):
""" Return the boolean value ``True`` if the case-lowered value of string
input ``s`` is any of ``t``, ``true``, ``y``, ``on``, or ``1``, otherwise
@@ -34,10 +36,10 @@ def asbool(s):
or ``False``, return it."""
if s is None:
return False
- if s in (True, False):
+ if isinstance(s, bool):
return s
s = str(s).strip()
- return s.lower() in ('t', 'true', 'y', 'yes', 'on', '1')
+ return s.lower() in truthy
def aslist_cronly(value):
if isinstance(value, string_types):