summaryrefslogtreecommitdiff
path: root/lib/sqlalchemy
diff options
context:
space:
mode:
authorMike Bayer <mike_mp@zzzcomputing.com>2022-01-10 22:11:50 -0500
committerMike Bayer <mike_mp@zzzcomputing.com>2022-01-11 09:27:58 -0500
commit3b77079321d35f63103ead5092d9eeeb5ef546ca (patch)
tree440d9e6d0f9e8ca92e57ba6ad5c48df42357a91f /lib/sqlalchemy
parent4e9fe6e3b7a72fc3b116403ea9b27e847b5bf186 (diff)
downloadsqlalchemy-3b77079321d35f63103ead5092d9eeeb5ef546ca.tar.gz
change state.load_options to a tuple
having this be an immutable sequence is safer and possibly lower overhead. The change here went in with no issues save for tests that asserted it was a set. InstanceState.load_options is only referred towards when the object is first loaded, and then within the logic that emits an object refresh as well as within a lazy loader. it's only accessed as a whole collection. Fixes: #7558 Change-Id: Id1adbec0f93bcfbfc934ec9cd39e71e74727845d
Diffstat (limited to 'lib/sqlalchemy')
-rw-r--r--lib/sqlalchemy/orm/context.py6
-rw-r--r--lib/sqlalchemy/orm/state.py2
-rw-r--r--lib/sqlalchemy/orm/strategies.py2
3 files changed, 5 insertions, 5 deletions
diff --git a/lib/sqlalchemy/orm/context.py b/lib/sqlalchemy/orm/context.py
index 8ec18b865..cba7cf07d 100644
--- a/lib/sqlalchemy/orm/context.py
+++ b/lib/sqlalchemy/orm/context.py
@@ -103,7 +103,7 @@ class QueryContext:
self.loaders_require_uniquing = False
self.params = params
- self.propagated_loader_options = {
+ self.propagated_loader_options = tuple(
# issue 7447.
# propagated loader options will be present on loaded InstanceState
# objects under state.load_options and are typically used by
@@ -118,14 +118,14 @@ class QueryContext:
cached_o
for cached_o in compile_state.select_statement._with_options
if cached_o.propagate_to_loaders and cached_o._is_compile_state
- } | {
+ ) + tuple(
# for user defined loader options that are not "compile state",
# those just need to be present as they are
uncached_o
for uncached_o in statement._with_options
if uncached_o.propagate_to_loaders
and not uncached_o._is_compile_state
- }
+ )
self.attributes = dict(compile_state.attributes)
diff --git a/lib/sqlalchemy/orm/state.py b/lib/sqlalchemy/orm/state.py
index e0eadefc4..01ee16a13 100644
--- a/lib/sqlalchemy/orm/state.py
+++ b/lib/sqlalchemy/orm/state.py
@@ -68,7 +68,7 @@ class InstanceState(interfaces.InspectionAttrInfo):
session_id = None
key = None
runid = None
- load_options = util.EMPTY_SET
+ load_options = ()
load_path = PathRegistry.root
insert_order = None
_strong_obj = None
diff --git a/lib/sqlalchemy/orm/strategies.py b/lib/sqlalchemy/orm/strategies.py
index a8a563952..beaf649b7 100644
--- a/lib/sqlalchemy/orm/strategies.py
+++ b/lib/sqlalchemy/orm/strategies.py
@@ -964,7 +964,7 @@ class LazyLoader(AbstractRelationshipLoader, util.MemoizedSlots):
if state.load_options or (loadopt and loadopt._extra_criteria):
effective_path = state.load_path[self.parent_property]
- opts = tuple(state.load_options)
+ opts = state.load_options
if loadopt and loadopt._extra_criteria:
use_get = False