]> git.ipfire.org Git - thirdparty/sqlalchemy/sqlalchemy.git/commitdiff
move ident regex to memoized
authorMike Bayer <mike_mp@zzzcomputing.com>
Sun, 28 Jun 2009 20:21:24 +0000 (20:21 +0000)
committerMike Bayer <mike_mp@zzzcomputing.com>
Sun, 28 Jun 2009 20:21:24 +0000 (20:21 +0000)
lib/sqlalchemy/sql/compiler.py

index 097be422b7f66ec65af197e74d09793bf34ffd5d..679187fe61ed57122b1211cd9710c13276f3d627 100644 (file)
@@ -1284,24 +1284,24 @@ class IdentifierPreparer(object):
         else:
             return (self.format_table(table, use_schema=False), )
 
+    @util.memoized_property
+    def _r_identifiers(self):
+        initial, final, escaped_final = \
+                 [re.escape(s) for s in
+                  (self.initial_quote, self.final_quote,
+                   self._escape_identifier(self.final_quote))]
+        r = re.compile(
+            r'(?:'
+            r'(?:%(initial)s((?:%(escaped)s|[^%(final)s])+)%(final)s'
+            r'|([^\.]+))(?=\.|$))+' %
+            { 'initial': initial,
+              'final': final,
+              'escaped': escaped_final })
+        return r
+        
     def unformat_identifiers(self, identifiers):
         """Unpack 'schema.table.column'-like strings into components."""
 
-        try:
-            r = self._r_identifiers
-        except AttributeError:
-            initial, final, escaped_final = \
-                     [re.escape(s) for s in
-                      (self.initial_quote, self.final_quote,
-                       self._escape_identifier(self.final_quote))]
-            r = re.compile(
-                r'(?:'
-                r'(?:%(initial)s((?:%(escaped)s|[^%(final)s])+)%(final)s'
-                r'|([^\.]+))(?=\.|$))+' %
-                { 'initial': initial,
-                  'final': final,
-                  'escaped': escaped_final })
-            self._r_identifiers = r
-
+        r = self._r_identifiers
         return [self._unescape_identifier(i)
                 for i in [a or b for a, b in r.findall(identifiers)]]