From 0ab0b9ef8a970584e5ef3fdf7d6943e456b95380 Mon Sep 17 00:00:00 2001 From: Chris McDonough Date: Thu, 8 Sep 2011 03:04:01 -0400 Subject: python set intersection doesnt special case strings, so using 'in' is a loop is many times faster --- pyramid/static.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/pyramid/static.py b/pyramid/static.py index d3075fec0..72a76a014 100644 --- a/pyramid/static.py +++ b/pyramid/static.py @@ -168,7 +168,11 @@ class static_view(object): return HTTPMovedPermanently(url) has_insecure_pathelement = set(['..', '.', '']).intersection -contains_slash = set(['/', os.sep]).intersection +seps = set(['/', os.sep]) +def contains_slash(item): + for sep in seps: + if sep in item: + return True @lru_cache(1000) def _secure_path(path_tuple): -- cgit v1.2.3