1. idank
  2. sqlalchemy

Commits

Mike Bayer  committed 0ae4e54

- significant speed improvement to ResultProxy, pre-caches
TypeEngine dialect implementations and saves on function calls
per column. drops the masseagerload test from 80K function calls
to 66K

  • Participants
  • Parent commits b54f999
  • Branches default

Comments (0)

Files changed (2)

File CHANGES

View file
  • Ignore whitespace
       behave more properly with regards to FROM clause #574 
     - fix to long name generation when using oid_column as an order by
       (oids used heavily in mapper queries)
+    - significant speed improvement to ResultProxy, pre-caches
+      TypeEngine dialect implementations and saves on function calls
+      per column
     - parenthesis are applied to clauses via a new _Grouping construct.
       uses operator precedence to more intelligently apply parenthesis 
       to clauses, provides cleaner nesting of clauses (doesnt mutate

File lib/sqlalchemy/engine/base.py

View file
  • Ignore whitespace
     def __init__(self, context):
         """ResultProxy objects are constructed via the execute() method on SQLEngine."""
         self.context = context
+        self.dialect = context.dialect
         self.closed = False
         self.cursor = context.cursor
         self.__echo = logging.is_debug_enabled(context.engine.logger)
         self._init_metadata()
         
-    dialect = property(lambda s:s.context.dialect)
     rowcount = property(lambda s:s.context.get_rowcount())
     connection = property(lambda s:s.context.connection)
     
         self.__props = {}
         self.__keys = []
         metadata = self.cursor.description
+
         if metadata is not None:
             for i, item in enumerate(metadata):
                 # sqlite possibly prepending table name to colnames so strip
                 colname = item[0].split('.')[-1]
                 if self.context.typemap is not None:
-                    rec = (self.context.typemap.get(colname.lower(), types.NULLTYPE), i)
+                    type = self.context.typemap.get(colname.lower(), types.NULLTYPE)
                 else:
-                    rec = (types.NULLTYPE, i)
+                    type = types.NULLTYPE
+                rec = (type, type.dialect_impl(self.dialect), i)
+
                 if rec[0] is None:
                     raise DBAPIError("None for metadata " + colname)
                 if self.__props.setdefault(colname.lower(), rec) is not rec:
 
     def _get_col(self, row, key):
         rec = self._convert_key(key)
-        return rec[0].dialect_impl(self.dialect).convert_result_value(row[rec[1]], self.dialect)
+        return rec[1].convert_result_value(row[rec[2]], self.dialect)
     
     def _fetchone_impl(self):
         return self.cursor.fetchone()
     """
     def _get_col(self, row, key):
         rec = self._convert_key(key)
-        return row[rec[1]]
+        return row[rec[2]]
     
     def _process_row(self, row):
         sup = super(BufferedColumnResultProxy, self)