diff options
| author | Mike Bayer <mike_mp@zzzcomputing.com> | 2020-06-19 00:32:00 -0400 |
|---|---|---|
| committer | Mike Bayer <mike_mp@zzzcomputing.com> | 2020-06-19 00:34:20 -0400 |
| commit | 699da7ecb96e9e1af8df8072d53199a560311260 (patch) | |
| tree | d59316fa85f5fce8b6fc25776602de05e6a75f5f /lib/sqlalchemy/sql/base.py | |
| parent | 5624430eb1d07c68d0931bc89f7146bc003fde19 (diff) | |
| download | sqlalchemy-699da7ecb96e9e1af8df8072d53199a560311260.tar.gz | |
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
Diffstat (limited to 'lib/sqlalchemy/sql/base.py')
| -rw-r--r-- | lib/sqlalchemy/sql/base.py | 10 |
1 files changed, 8 insertions, 2 deletions
diff --git a/lib/sqlalchemy/sql/base.py b/lib/sqlalchemy/sql/base.py index 5f2ce8f14..4c603b6dd 100644 --- a/lib/sqlalchemy/sql/base.py +++ b/lib/sqlalchemy/sql/base.py @@ -495,8 +495,14 @@ class Generative(HasMemoized): def _generate(self): skip = self._memoized_keys - s = self.__class__.__new__(self.__class__) - s.__dict__ = {k: v for k, v in self.__dict__.items() if k not in skip} + cls = self.__class__ + s = cls.__new__(cls) + if skip: + s.__dict__ = { + k: v for k, v in self.__dict__.items() if k not in skip + } + else: + s.__dict__ = self.__dict__.copy() return s |
