summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChris McDonough <chrism@agendaless.com>2008-12-18 19:08:43 +0000
committerChris McDonough <chrism@agendaless.com>2008-12-18 19:08:43 +0000
commitb89ec92e6a47181229760a5546abd7ef53bbf87a (patch)
treed14ff4371a3f7c15d4e9711e7dd86ae342d9979b
parent38e09dc89a36f801f3892ae99fa784344ca8cfe8 (diff)
downloadpyramid-b89ec92e6a47181229760a5546abd7ef53bbf87a.tar.gz
pyramid-b89ec92e6a47181229760a5546abd7ef53bbf87a.tar.bz2
pyramid-b89ec92e6a47181229760a5546abd7ef53bbf87a.zip
Use ``ob.__class__ is unicode`` (~ 15% faster).
-rw-r--r--CHANGES.txt5
-rw-r--r--repoze/bfg/traversal.py2
2 files changed, 4 insertions, 3 deletions
diff --git a/CHANGES.txt b/CHANGES.txt
index 4cca670d3..a98d135d1 100644
--- a/CHANGES.txt
+++ b/CHANGES.txt
@@ -2,9 +2,10 @@ Next release
- Speed up ``traversal.model_url`` execution by using a custom url
quoting function instead of Python's ``urllib.quote``, by caching
- URL path segment quoting and encoding results, and by disusing
+ URL path segment quoting and encoding results, by disusing
Python's ``urlparse.urljoin`` in favor of a simple string
- concatenation.
+ concatenation, and by using ``ob.__class__ is unicode`` rather
+ than ``isinstance(ob, unicode)`` in one strategic place.
0.5.5 (12/17/2008)
diff --git a/repoze/bfg/traversal.py b/repoze/bfg/traversal.py
index 37f9e0d2e..f4cc25935 100644
--- a/repoze/bfg/traversal.py
+++ b/repoze/bfg/traversal.py
@@ -130,7 +130,7 @@ def _urlsegment(s):
reencode or re-url-quote it """
result = _segment_cache.get(s)
if result is None:
- if isinstance(s, unicode):
+ if s.__class__ is unicode: # isinstance slighly slower (~15%)
result = _url_quote(s.encode('utf-8'))
else:
result = _url_quote(s)