diff options
author | Mike Bayer <mike_mp@zzzcomputing.com> | 2007-08-14 21:53:32 +0000 |
---|---|---|
committer | Mike Bayer <mike_mp@zzzcomputing.com> | 2007-08-14 21:53:32 +0000 |
commit | 087f235c33c1be4e0778231e8344a50dc4005c59 (patch) | |
tree | d47c35d1e520e43c05ec869304870c0b6c87f736 /lib/sqlalchemy/databases/access.py | |
parent | e58063aa91d893d76e9f34fbc3ea21818185844d (diff) | |
download | sqlalchemy-087f235c33c1be4e0778231e8344a50dc4005c59.tar.gz |
- merged "fasttypes" branch. this branch changes the signature
of convert_bind_param() and convert_result_value() to callable-returning
bind_processor() and result_processor() methods. if no callable is
returned, no pre/post processing function is called.
- hooks added throughout base/sql/defaults to optimize the calling
of bind param/result processors so that method call overhead is minimized.
special cases added for executemany() scenarios such that unneeded "last row id"
logic doesn't kick in, parameters aren't excessively traversed.
- new performance tests show a combined mass-insert/mass-select test as having 68%
fewer function calls than the same test run against 0.3.
- general performance improvement of result set iteration is around 10-20%.
Diffstat (limited to 'lib/sqlalchemy/databases/access.py')
-rw-r--r-- | lib/sqlalchemy/databases/access.py | 72 |
1 files changed, 40 insertions, 32 deletions
diff --git a/lib/sqlalchemy/databases/access.py b/lib/sqlalchemy/databases/access.py index 3c06822ae..6bf8b96e9 100644 --- a/lib/sqlalchemy/databases/access.py +++ b/lib/sqlalchemy/databases/access.py @@ -11,16 +11,18 @@ import sqlalchemy.engine.default as default class AcNumeric(types.Numeric): - def convert_result_value(self, value, dialect): - return value - - def convert_bind_param(self, value, dialect): - if value is None: - # Not sure that this exception is needed - return value - else: - return str(value) + def result_processor(self, dialect): + return None + def bind_processor(self, dialect): + def process(value): + if value is None: + # Not sure that this exception is needed + return value + else: + return str(value) + return process + def get_col_spec(self): return "NUMERIC" @@ -28,12 +30,14 @@ class AcFloat(types.Float): def get_col_spec(self): return "FLOAT" - def convert_bind_param(self, value, dialect): + def bind_processor(self, dialect): """By converting to string, we can use Decimal types round-trip.""" - if not value is None: - return str(value) - return None - + def process(value): + if not value is None: + return str(value) + return None + return process + class AcInteger(types.Integer): def get_col_spec(self): return "INTEGER" @@ -72,11 +76,11 @@ class AcUnicode(types.Unicode): def get_col_spec(self): return "TEXT" + (self.length and ("(%d)" % self.length) or "") - def convert_bind_param(self, value, dialect): - return value + def bind_processor(self, dialect): + return None - def convert_result_value(self, value, dialect): - return value + def result_processor(self, dialect): + return None class AcChar(types.CHAR): def get_col_spec(self): @@ -90,21 +94,25 @@ class AcBoolean(types.Boolean): def get_col_spec(self): return "YESNO" - def convert_result_value(self, value, dialect): - if value is None: - return None - return value and True or False - - def convert_bind_param(self, value, dialect): - if value is True: - return 1 - elif value is False: - return 0 - elif value is None: - return None - else: + def result_processor(self, dialect): + def process(value): + if value is None: + return None return value and True or False - + return process + + def bind_processor(self, dialect): + def process(value): + if value is True: + return 1 + elif value is False: + return 0 + elif value is None: + return None + else: + return value and True or False + return process + class AcTimeStamp(types.TIMESTAMP): def get_col_spec(self): return "TIMESTAMP" |