diff options
author | Mike Bayer <mike_mp@zzzcomputing.com> | 2020-03-09 17:12:35 -0400 |
---|---|---|
committer | Mike Bayer <mike_mp@zzzcomputing.com> | 2020-04-01 16:12:23 -0400 |
commit | a9b62055bfa61c11e9fe0b2984437e2c3e32bf0e (patch) | |
tree | 366027c7069edd56d49e9d540ae6a14fbe9e16fe /lib/sqlalchemy/sql/dml.py | |
parent | e6250123a30e457068878394e49b7ca07ca4d3b0 (diff) | |
download | sqlalchemy-a9b62055bfa61c11e9fe0b2984437e2c3e32bf0e.tar.gz |
Try to measure new style caching in the ORM, take two
Supercedes: If78fbb557c6f2cae637799c3fec2cbc5ac248aaf
Trying to see if by making the cache key memoized, we
still can have the older "identity" form of caching
which is the cheapest of all, at the same time as the
newer "cache key each time" version that is not nearly
as cheap; but still much cheaper than no caching at all.
Also needed is a per-execution update of _keymap when
we invoke from a cached select, so that Column objects
that are anonymous or otherwise adapted will match up.
this is analogous to the adaption of bound parameters
from the cache key.
Adds test coverage for the keymap / construct_params()
changes related to caching. Also hones performance
to a large extent for statement construction and
cache key generation.
Also includes a new memoized attribute
approach that vastly simplifies the previous approach
of "group_expirable_memoized_property" and finally
integrates cleanly with _clone(), _generate(), etc.
no more hardcoding of attributes is needed, as well
as that most _reset_memoization() calls are no longer
needed as the reset is inherent in a _generate() call;
this also has dramatic performance improvements.
Change-Id: I95c560ffcbfa30b26644999412fb6a385125f663
Diffstat (limited to 'lib/sqlalchemy/sql/dml.py')
-rw-r--r-- | lib/sqlalchemy/sql/dml.py | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/lib/sqlalchemy/sql/dml.py b/lib/sqlalchemy/sql/dml.py index 5c75e068f..cbcf54d1c 100644 --- a/lib/sqlalchemy/sql/dml.py +++ b/lib/sqlalchemy/sql/dml.py @@ -14,6 +14,7 @@ from . import coercions from . import roles from .base import _from_objects from .base import _generative +from .base import ColumnCollection from .base import CompileState from .base import DialectKWArgs from .base import Executable @@ -364,6 +365,28 @@ class UpdateBase( """ self._returning = cols + def _exported_columns_iterator(self): + """Return the RETURNING columns as a sequence for this statement. + + .. versionadded:: 1.4 + + """ + + return self._returning or () + + @property + def exported_columns(self): + """Return the RETURNING columns as a column collection for this + statement. + + .. versionadded:: 1.4 + + """ + # TODO: no coverage here + return ColumnCollection( + (c.key, c) for c in self._exported_columns_iterator() + ).as_immutable() + @_generative def with_hint(self, text, selectable=None, dialect_name="*"): """Add a table hint for a single table to this |