summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--CHANGES42
-rw-r--r--lib/sqlalchemy/cextension/resultproxy.c4
-rw-r--r--lib/sqlalchemy/engine/base.py21
3 files changed, 37 insertions, 30 deletions
diff --git a/CHANGES b/CHANGES
index 81ba79de1..1042be0e1 100644
--- 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
diff --git a/lib/sqlalchemy/cextension/resultproxy.c b/lib/sqlalchemy/cextension/resultproxy.c
index 14ea1828e..048d74d74 100644
--- a/lib/sqlalchemy/cextension/resultproxy.c
+++ b/lib/sqlalchemy/cextension/resultproxy.c
@@ -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 */
};
diff --git a/lib/sqlalchemy/engine/base.py b/lib/sqlalchemy/engine/base.py
index 4dc9665c0..ff475ee3d 100644
--- a/lib/sqlalchemy/engine/base.py
+++ b/lib/sqlalchemy/engine/base.py
@@ -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)