]> git.ipfire.org Git - thirdparty/sqlalchemy/sqlalchemy.git/commitdiff
- fix C version of rowproxy pickling so that it pickles to the same format
authorGaëtan de Menten <gdementen@gmail.com>
Sun, 14 Feb 2010 21:21:40 +0000 (21:21 +0000)
committerGaëtan de Menten <gdementen@gmail.com>
Sun, 14 Feb 2010 21:21:40 +0000 (21:21 +0000)
  as the Python version.
- changelog my earlier processor optimization work

CHANGES
lib/sqlalchemy/cextension/resultproxy.c
lib/sqlalchemy/engine/base.py

diff --git a/CHANGES b/CHANGES
index 81ba79de106f0d9444ecc3224426f1a92337b237..1042be0e1d84080641904e17e4b91d6780ff99c6 100644 (file)
--- a/CHANGES
+++ b/CHANGES
@@ -67,15 +67,6 @@ CHANGES
     [ticket:1689]
       
 - sql
-  - Added an optional C extension to speed up the sql layer by
-    reimplementing RowProxy and the most common result processors.
-    The actual speedups will depend heavily on your DBAPI and
-    the mix of datatypes used in your tables, and can vary from
-    a 30% improvement to more than 200%.  It also provides a modest
-    (~15-20%) indirect improvement to ORM speed for large queries.
-    Note that it is *not* built/installed by default.
-    See README for installation instructions.
-
   - The most common result processors conversion function were
     moved to the new "processors" module.  Dialect authors are
     encouraged to use those functions whenever they correspond
@@ -121,7 +112,17 @@ CHANGES
     any ClauseElement that supports the @_generative
     decorator - these may also become "public" for the benefit
     of the compiler extension at some point.
-    
+
+- engines
+  - Added an optional C extension to speed up the sql layer by
+    reimplementing RowProxy and the most common result processors.
+    The actual speedups will depend heavily on your DBAPI and
+    the mix of datatypes used in your tables, and can vary from
+    a 30% improvement to more than 200%.  It also provides a modest
+    (~15-20%) indirect improvement to ORM speed for large queries.
+    Note that it is *not* built/installed by default.
+    See README for installation instructions.
+
 - mysql
   - Fixed reflection bug whereby when COLLATE was present, 
     nullable flag and server defaults would not be reflected.
@@ -545,11 +546,13 @@ CHANGES
     the parent ResultProxy instead, or use autoclose.
     
   - ResultProxy internals have been overhauled to greatly reduce
-    method call counts when fetching columns that have no 
-    type-level processing applied.   Provides a 100% speed
-    improvement when fetching large result sets with no unicode
-    conversion as tuples.  Many thanks to Elixir's Gaëtan de Menten
-    for this dramatic improvement !  [ticket:1586]
+    method call counts when fetching columns.  Can provide a large 
+    speed improvement (up to more than 100%) when fetching large 
+    result sets.  The improvement is larger when fetching columns 
+    that have no type-level processing applied and when using 
+    results as tuples (instead of as dictionaries).  Many 
+    thanks to Elixir's Gaëtan de Menten for this dramatic 
+    improvement !  [ticket:1586]
 
   - Databases which rely upon postfetch of "last inserted id"
     to get at a generated sequence value (i.e. MySQL, MS-SQL)
@@ -1027,6 +1030,15 @@ CHANGES
       is a Python unicode.   This allows vast performance
       increases for native-unicode DBAPIs, including
       pysqlite/sqlite3, psycopg2, and pg8000.
+
+    - Most types result processors have been checked for possible speed
+      improvements. Specifically, the following generic types have been 
+      optimized, resulting in varying speed improvements: 
+      Unicode, PickleType, Interval, TypeDecorator, Binary. 
+      Also the following dbapi-specific implementations have been improved:
+      Time, Date and DateTime on Sqlite, ARRAY on Postgresql,
+      Time on MySQL, Numeric(as_decimal=False) on MySQL, oursql and 
+      pypostgresql, DateTime on cx_oracle and LOB-based types on cx_oracle.
       
     - Reflection of types now returns the exact UPPERCASE
       type within types.py, or the UPPERCASE type within
index 14ea1828e571312b947c2c5ae4e183dd790d8a50..048d74d74b2a44e8ad413931a7abca3a204d9620 100644 (file)
@@ -26,7 +26,7 @@ typedef struct {
  ****************/
 
 static PyObject *
-rowproxy_reconstructor(PyObject *self, PyObject *args)
+safe_rowproxy_reconstructor(PyObject *self, PyObject *args)
 {
     PyObject *cls, *state, *tmp;
     BaseRowProxy *obj;
@@ -560,7 +560,7 @@ static PyTypeObject BaseRowProxyType = {
 
 
 static PyMethodDef module_methods[] = {
-    {"rowproxy_reconstructor", rowproxy_reconstructor, METH_VARARGS,
+    {"safe_rowproxy_reconstructor", safe_rowproxy_reconstructor, METH_VARARGS,
      "reconstruct a RowProxy instance from its pickled form."},
     {NULL, NULL, 0, NULL}        /* Sentinel */
 };
index 4dc9665c0c841d0adb8821fe7527dc6963e232a9..ff475ee3d2e08a137d2edda4acb9fa59fed78ecd 100644 (file)
@@ -1596,21 +1596,16 @@ def _proxy_connection_cls(cls, proxy):
 
 # This reconstructor is necessary so that pickles with the C extension or
 # without use the same Binary format.
-# We need a different reconstructor on the C extension so that we can
-# add extra checks that fields have correctly been initialized by
-# __setstate__.
 try:
-    from sqlalchemy.cresultproxy import rowproxy_reconstructor
-
-    # this is a hack so that the reconstructor function is pickled with the
-    # same name as without the C extension.
-    # BUG: It fails for me if I run the "python" interpreter and 
-    # then say "import sqlalchemy":
-    # TypeError: 'builtin_function_or_method' object has only read-only attributes (assign to .__module__)
-    # However, if I run the tests with nosetests, it succeeds !  
-    # I've verified with pdb etc. that this is the case.
-    #rowproxy_reconstructor.__module__ = 'sqlalchemy.engine.base'
+    # We need a different reconstructor on the C extension so that we can
+    # add extra checks that fields have correctly been initialized by
+    # __setstate__.
+    from sqlalchemy.cresultproxy import safe_rowproxy_reconstructor
 
+    # The extra function embedding is needed so that the reconstructor function
+    # has the same signature whether or not the extension is present.
+    def rowproxy_reconstructor(cls, state):
+        return safe_rowproxy_reconstructor(cls, state)
 except ImportError:
     def rowproxy_reconstructor(cls, state):
         obj = cls.__new__(cls)