summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMike Bayer <mike_mp@zzzcomputing.com>2008-03-30 22:01:15 +0000
committerMike Bayer <mike_mp@zzzcomputing.com>2008-03-30 22:01:15 +0000
commitbd0bcc9f57e31bcc9a5f99e22daa6bfe93b24c72 (patch)
tree26903ef935ead5e0de08baacaa9f08f6d7a84a06
parent7512b5e5482ea8a01095f98f82f1380f19a07110 (diff)
downloadsqlalchemy-bd0bcc9f57e31bcc9a5f99e22daa6bfe93b24c72.tar.gz
using concatenated strings as keys in generated_ids collection; they hash slightly faster than tuples
-rw-r--r--lib/sqlalchemy/sql/compiler.py14
1 files changed, 8 insertions, 6 deletions
diff --git a/lib/sqlalchemy/sql/compiler.py b/lib/sqlalchemy/sql/compiler.py
index 76e2ca260..71d12b6be 100644
--- a/lib/sqlalchemy/sql/compiler.py
+++ b/lib/sqlalchemy/sql/compiler.py
@@ -418,8 +418,9 @@ class DefaultCompiler(engine.Compiled):
return bind_name
def _truncated_identifier(self, ident_class, name):
- if (ident_class, name) in self.generated_ids:
- return self.generated_ids[(ident_class, name)]
+ key = ident_class + "|" + name
+ if key in self.generated_ids:
+ return self.generated_ids[key]
anonname = ANONYMOUS_LABEL.sub(self._process_anon, name)
@@ -429,18 +430,19 @@ class DefaultCompiler(engine.Compiled):
self.generated_ids[ident_class] = counter + 1
else:
truncname = anonname
- self.generated_ids[(ident_class, name)] = truncname
+ self.generated_ids[key] = truncname
return truncname
def _process_anon(self, match):
(ident, derived) = match.group(1,2)
- key = ('anonymous', ident)
+ key = 'anonymous|' + ident
if key in self.generated_ids:
return self.generated_ids[key]
else:
- anonymous_counter = self.generated_ids.get(('anon_counter', derived), 1)
+ counter_key = "anon_counter|" + derived
+ anonymous_counter = self.generated_ids.get(counter_key, 1)
newname = derived + "_" + str(anonymous_counter)
- self.generated_ids[('anon_counter', derived)] = anonymous_counter + 1
+ self.generated_ids[counter_key] = anonymous_counter + 1
self.generated_ids[key] = newname
return newname