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/sql/base.py | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) (limited to 'lib/sqlalchemy/sql') 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 -- cgit v1.2.1