From 699da7ecb96e9e1af8df8072d53199a560311260 Mon Sep 17 00:00:00 2001 From: Mike Bayer Date: Fri, 19 Jun 2020 00:32:00 -0400 Subject: perf tweaks - avoid abc checks in distill_20 - ColumnEntity subclasses are unique to their compile state and have no querycontext specific state. They can do a simple memoize of their fetch_column without using attributes, and they can memoize their _getter() too so that it goes into the cache, just like instance_processor() does. - unify ORMColumnEntity and RawColumnEntity for the row processor part, add some test coverage for the case where it is used in a from_statement - do a faster generate if there are no memoized entries - query._params is always immutabledict Change-Id: I1e2dfe607a1749b5b434fc11f9348ee631501dfa --- lib/sqlalchemy/engine/util.py | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) (limited to 'lib/sqlalchemy/engine') diff --git a/lib/sqlalchemy/engine/util.py b/lib/sqlalchemy/engine/util.py index 8fb04646f..fc0260ae2 100644 --- a/lib/sqlalchemy/engine/util.py +++ b/lib/sqlalchemy/engine/util.py @@ -8,6 +8,7 @@ from .. import exc from .. import util from ..util import collections_abc +from ..util import immutabledict def connection_memoize(key): @@ -85,9 +86,11 @@ _no_kw = util.immutabledict() def _distill_params_20(params): + # TODO: this has to be in C if params is None: return _no_tuple, _no_kw, [] - elif isinstance(params, collections_abc.MutableSequence): # list + elif isinstance(params, list): + # collections_abc.MutableSequence): # avoid abc.__instancecheck__ if params and not isinstance( params[0], (collections_abc.Mapping, tuple) ): @@ -99,7 +102,9 @@ def _distill_params_20(params): return tuple(params), _no_kw, params elif isinstance( params, - (collections_abc.Sequence, collections_abc.Mapping), # tuple or dict + (tuple, dict, immutabledict), + # avoid abc.__instancecheck__ + # (collections_abc.Sequence, collections_abc.Mapping), ): return _no_tuple, params, [params] else: -- cgit v1.2.1