diff options
author | Mike Bayer <mike_mp@zzzcomputing.com> | 2010-02-13 21:16:08 +0000 |
---|---|---|
committer | Mike Bayer <mike_mp@zzzcomputing.com> | 2010-02-13 21:16:08 +0000 |
commit | aedcd6aea6aa3b4601bbc26f5fc23c084c8996ac (patch) | |
tree | bcf773463439c124b0ea8c655e3ac461c26686b5 /lib/sqlalchemy/orm/state.py | |
parent | f4573f73d0c7f7ce5b184e6c227d0e4f406643a5 (diff) | |
download | sqlalchemy-aedcd6aea6aa3b4601bbc26f5fc23c084c8996ac.tar.gz |
- reduced a bit of overhead in attribute expiration, particularly
the version called by column loaders on an incomplete row (i.e.
joined table inheritance). there are more dramatic changes
that can be made here but this one is conservative so far
as far as how much we're altering how InstanceState tracks
"expired" attributes.
Diffstat (limited to 'lib/sqlalchemy/orm/state.py')
-rw-r--r-- | lib/sqlalchemy/orm/state.py | 31 |
1 files changed, 25 insertions, 6 deletions
diff --git a/lib/sqlalchemy/orm/state.py b/lib/sqlalchemy/orm/state.py index 4bb9219f4..a9494a50e 100644 --- a/lib/sqlalchemy/orm/state.py +++ b/lib/sqlalchemy/orm/state.py @@ -239,9 +239,30 @@ class InstanceState(object): return set( key for key in self.manager.iterkeys() if key not in self.committed_state and key not in self.dict) - - def expire_attributes(self, attribute_names, instance_dict=None): - self.expired_attributes = set(self.expired_attributes) + + def expire_attribute_pre_commit(self, dict_, key): + """a fast expire that can be called by column loaders during a load. + + The additional bookkeeping is finished up in commit_all(). + + This method is actually called a lot with joined-table + loading, when the second table isn't present in the result. + + """ + # TODO: yes, this is still a little too busy. + # need to more cleanly separate out handling + # for the various AttributeImpls and the contracts + # they wish to maintain with their strategies + if not self.expired_attributes: + self.expired_attributes = set(self.expired_attributes) + + dict_.pop(key, None) + self.callables[key] = self + self.expired_attributes.add(key) + + def expire_attributes(self, dict_, attribute_names, instance_dict=None): + if not self.expired_attributes: + self.expired_attributes = set(self.expired_attributes) if attribute_names is None: attribute_names = self.manager.keys() @@ -258,7 +279,6 @@ class InstanceState(object): filter_deferred = True else: filter_deferred = False - dict_ = self.dict for key in attribute_names: impl = self.manager[key].impl @@ -354,8 +374,7 @@ class InstanceState(object): self.committed_state = {} self.pending = {} - - # unexpire attributes which have loaded + if self.expired_attributes: for key in self.expired_attributes.intersection(dict_): self.callables.pop(key, None) |