summaryrefslogtreecommitdiff
path: root/lib/sqlalchemy/orm/identity.py
diff options
context:
space:
mode:
authorMike Bayer <mike_mp@zzzcomputing.com>2015-02-18 16:08:19 -0500
committerMike Bayer <mike_mp@zzzcomputing.com>2015-02-18 16:08:19 -0500
commit3209a73b92e17dd351a50c41352791baeefcd846 (patch)
tree2598487e5032baa9847fa11fbe9b34ee64596f7e /lib/sqlalchemy/orm/identity.py
parent3eff76c4b0c234717e6d8a157ef6883b72694927 (diff)
downloadsqlalchemy-3209a73b92e17dd351a50c41352791baeefcd846.tar.gz
- Mapped state internals have been reworked to allow for a 50% reduction
in callcounts specific to the "expiration" of objects, as in the "auto expire" feature of :meth:`.Session.commit` and for :meth:`.Session.expire_all`, as well as in the "cleanup" step which occurs when object states are garbage collected. fixes #3307
Diffstat (limited to 'lib/sqlalchemy/orm/identity.py')
-rw-r--r--lib/sqlalchemy/orm/identity.py9
1 files changed, 8 insertions, 1 deletions
diff --git a/lib/sqlalchemy/orm/identity.py b/lib/sqlalchemy/orm/identity.py
index 24dd47859..769010950 100644
--- a/lib/sqlalchemy/orm/identity.py
+++ b/lib/sqlalchemy/orm/identity.py
@@ -44,7 +44,8 @@ class IdentityMap(object):
def _manage_removed_state(self, state):
del state._instance_dict
- self._modified.discard(state)
+ if state.modified:
+ self._modified.discard(state)
def _dirty_states(self):
return self._modified
@@ -186,6 +187,9 @@ class WeakInstanceDict(IdentityMap):
else:
return list(self._dict.values())
+ def _fast_discard(self, state):
+ self._dict.pop(state.key, None)
+
def discard(self, state):
st = self._dict.pop(state.key, None)
if st:
@@ -264,6 +268,9 @@ class StrongInstanceDict(IdentityMap):
self._dict[key] = state.obj()
state._instance_dict = self._wr
+ def _fast_discard(self, state):
+ self._dict.pop(state.key, None)
+
def discard(self, state):
obj = self._dict.pop(state.key, None)
if obj is not None: