summaryrefslogtreecommitdiff
path: root/lib/sqlalchemy/orm/identity.py
diff options
context:
space:
mode:
authorMike Bayer <mike_mp@zzzcomputing.com>2014-08-29 13:11:52 -0400
committerMike Bayer <mike_mp@zzzcomputing.com>2014-08-29 13:11:52 -0400
commit9d25eae8eec8c090339a01c03445bdf04a0840f5 (patch)
treed2184236c405081be62635264719b2971415adf9 /lib/sqlalchemy/orm/identity.py
parenta95b0a5b6e132e44bcc9cc4429526533ab964787 (diff)
downloadsqlalchemy-9d25eae8eec8c090339a01c03445bdf04a0840f5.tar.gz
- use a faster discard when loading
- don't do a bool on identity map since it calls __len__
Diffstat (limited to 'lib/sqlalchemy/orm/identity.py')
-rw-r--r--lib/sqlalchemy/orm/identity.py13
1 files changed, 13 insertions, 0 deletions
diff --git a/lib/sqlalchemy/orm/identity.py b/lib/sqlalchemy/orm/identity.py
index 0fa541194..24dd47859 100644
--- a/lib/sqlalchemy/orm/identity.py
+++ b/lib/sqlalchemy/orm/identity.py
@@ -187,6 +187,12 @@ class WeakInstanceDict(IdentityMap):
return list(self._dict.values())
def discard(self, state):
+ st = self._dict.pop(state.key, None)
+ if st:
+ assert st is state
+ self._manage_removed_state(state)
+
+ def safe_discard(self, state):
if state.key in self._dict:
st = self._dict[state.key]
if st is state:
@@ -259,6 +265,13 @@ class StrongInstanceDict(IdentityMap):
state._instance_dict = self._wr
def discard(self, state):
+ obj = self._dict.pop(state.key, None)
+ if obj is not None:
+ self._manage_removed_state(state)
+ st = attributes.instance_state(obj)
+ assert st is state
+
+ def safe_discard(self, state):
if state.key in self._dict:
obj = self._dict[state.key]
st = attributes.instance_state(obj)