diff options
| author | Jason Kirtland <jek@discorporate.us> | 2007-08-21 07:55:43 +0000 |
|---|---|---|
| committer | Jason Kirtland <jek@discorporate.us> | 2007-08-21 07:55:43 +0000 |
| commit | 47670faa30c99fa2bd92bd9caf35cd30470534b5 (patch) | |
| tree | b64cbb4875612790e4d4703aa7bb45a937e5feb7 /lib/sqlalchemy/sql/compiler.py | |
| parent | 6228e72cb15be6e84260440d20369c91858b4640 (diff) | |
| download | sqlalchemy-47670faa30c99fa2bd92bd9caf35cd30470534b5.tar.gz | |
A couple critical path optimizations
(some sql operations faster by nearly 10% wallclock, general orm around 3%)
Diffstat (limited to 'lib/sqlalchemy/sql/compiler.py')
| -rw-r--r-- | lib/sqlalchemy/sql/compiler.py | 15 |
1 files changed, 10 insertions, 5 deletions
diff --git a/lib/sqlalchemy/sql/compiler.py b/lib/sqlalchemy/sql/compiler.py index 59964178c..99cfa0470 100644 --- a/lib/sqlalchemy/sql/compiler.py +++ b/lib/sqlalchemy/sql/compiler.py @@ -212,7 +212,7 @@ class DefaultCompiler(engine.Compiled, visitors.ClauseVisitor): return None - def construct_params(self, params): + def construct_params(self, params=None): """Return a sql.util.ClauseParameters object. Combines the given bind parameter dictionary (string keys to object values) @@ -223,15 +223,20 @@ class DefaultCompiler(engine.Compiled, visitors.ClauseVisitor): d = sql_util.ClauseParameters(self.dialect, self.positiontup) - pd = self.parameters or {} - pd.update(params) + if self.parameters is None: + pd = {} + else: + pd = self.parameters + if params is not None: + pd.update(params) + bind_names = self.bind_names for key, bind in self.binds.iteritems(): - d.set_parameter(bind, pd.get(key, bind.value), self.bind_names[bind]) + d.set_parameter(bind, pd.get(key, bind.value), bind_names[bind]) return d - params = property(lambda self:self.construct_params({}), doc="""Return the `ClauseParameters` corresponding to this compiled object. + params = property(lambda self:self.construct_params(), doc="""Return the `ClauseParameters` corresponding to this compiled object. A shortcut for `construct_params()`.""") def default_from(self): |
