summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorR. Tyler Ballance <tyler@monkeypox.org>2009-10-12 21:48:58 -0700
committerR. Tyler Ballance <tyler@monkeypox.org>2009-10-15 07:30:41 -0700
commite354cde7e5b3d42c4ff34f451ada310a8fe558fc (patch)
treea3d1291ac9c85459bdd2528f27b9f8f83ff061be
parentc93d8b2020cbdd0b300982210cdd44382d7fc38e (diff)
downloadpython-cheetah-e354cde7e5b3d42c4ff34f451ada310a8fe558fc.tar.gz
Remove unnecessary dir()/set() calls in Template.__init__()
When running cheetah.Tests.Performance.DynamicMethodCompilationTest with 100000 iterations set, Template.__init__() is the most performance sensitive call. Prior to this commit: ncalls tottime percall cumtime percall filename:lineno(function) 100000 12.558 0.000 15.274 0.000 Template.py:1025(__init__) After this commit: ncalls tottime percall cumtime percall filename:lineno(function) 100000 1.263 0.000 3.541 0.000 Template.py:1025(__init__) That code need not execute every time __init__ is called
-rw-r--r--cheetah/Template.py5
1 files changed, 2 insertions, 3 deletions
diff --git a/cheetah/Template.py b/cheetah/Template.py
index 01cf676..c903460 100644
--- a/cheetah/Template.py
+++ b/cheetah/Template.py
@@ -1213,11 +1213,10 @@ class Template(Servlet):
##################################################
## Setup instance state attributes used during the life of template
## post-compile
- reserved_searchlist = dir(self)
if searchList:
for namespace in searchList:
if isinstance(namespace, dict):
- intersection = set(reserved_searchlist) & set(namespace.keys())
+ intersection = Reserved_SearchList & set(namespace.keys())
warn = False
if intersection:
warn = True
@@ -1832,7 +1831,7 @@ class Template(Servlet):
return dic
T = Template # Short and sweet for debugging at the >>> prompt.
-
+Reserved_SearchList = set(dir(Template))
def genParserErrorFromPythonException(source, file, generatedPyCode, exception):