summaryrefslogtreecommitdiff
path: root/lib/sqlalchemy/sql/compiler.py
diff options
context:
space:
mode:
authorMike Bayer <mike_mp@zzzcomputing.com>2010-12-12 17:50:25 -0500
committerMike Bayer <mike_mp@zzzcomputing.com>2010-12-12 17:50:25 -0500
commit1125a4b8b1a7b41111396b5b58887047a847b59e (patch)
treee15bda26a23b735a9fbf74d085e5e0e7411c0b84 /lib/sqlalchemy/sql/compiler.py
parentb12caa18b5b05e30078bcd85f48c66cdd17965e7 (diff)
downloadsqlalchemy-1125a4b8b1a7b41111396b5b58887047a847b59e.tar.gz
- another easy win, cache the calc of bind processors in the compiled object
Diffstat (limited to 'lib/sqlalchemy/sql/compiler.py')
-rw-r--r--lib/sqlalchemy/sql/compiler.py19
1 files changed, 19 insertions, 0 deletions
diff --git a/lib/sqlalchemy/sql/compiler.py b/lib/sqlalchemy/sql/compiler.py
index eb339cf1d..d5b877a35 100644
--- a/lib/sqlalchemy/sql/compiler.py
+++ b/lib/sqlalchemy/sql/compiler.py
@@ -250,7 +250,26 @@ class SQLCompiler(engine.Compiled):
# a map which tracks "truncated" names based on dialect.label_length
# or dialect.max_identifier_length
self.truncated_names = {}
+
+ # other memoized things
+ self._memos ={}
+ def _get_bind_processors(self, dialect):
+ key = 'bind_processors', dialect.__class__, \
+ dialect.server_version_info
+
+ if key not in self._memos:
+ self._memos[key] = processors = dict(
+ (key, value) for key, value in
+ ( (self.bind_names[bindparam],
+ bindparam.bind_processor(dialect))
+ for bindparam in self.bind_names )
+ if value is not None
+ )
+ return processors
+ else:
+ return self._memos[key]
+
def is_subquery(self):
return len(self.stack) > 1