From 30a50cc46aa836e24ebcbb889cbee583c511af82 Mon Sep 17 00:00:00 2001 From: Mike Bayer Date: Tue, 26 Nov 2013 23:24:13 -0500 Subject: - the wrapped memoized_property here was not working, as the attribute name didn't match. use straight memoized_props here for now, add a perf test to check it --- lib/sqlalchemy/orm/attributes.py | 28 ++++++++++++++++++---------- 1 file changed, 18 insertions(+), 10 deletions(-) (limited to 'lib/sqlalchemy/orm/attributes.py') diff --git a/lib/sqlalchemy/orm/attributes.py b/lib/sqlalchemy/orm/attributes.py index e3c6a3512..ce6200e71 100644 --- a/lib/sqlalchemy/orm/attributes.py +++ b/lib/sqlalchemy/orm/attributes.py @@ -355,12 +355,6 @@ class Event(object): self.op = op self.parent_token = self.impl.parent_token - @classmethod - def _token_gen(self, op): - @util.memoized_property - def gen(self): - return Event(self, op) - return gen @property def key(self): @@ -687,8 +681,17 @@ class ScalarAttributeImpl(AttributeImpl): state._modified_event(dict_, self, old) dict_[self.key] = value - _replace_token = _append_token = Event._token_gen(OP_REPLACE) - _remove_token = Event._token_gen(OP_REMOVE) + @util.memoized_property + def _replace_token(self): + return Event(self, OP_REPLACE) + + @util.memoized_property + def _append_token(self): + return Event(self, OP_REPLACE) + + @util.memoized_property + def _remove_token(self): + return Event(self, OP_REMOVE) def fire_replace_event(self, state, dict_, value, previous, initiator): for fn in self.dispatch.set: @@ -879,8 +882,13 @@ class CollectionAttributeImpl(AttributeImpl): return [(instance_state(o), o) for o in current] - _append_token = Event._token_gen(OP_APPEND) - _remove_token = Event._token_gen(OP_REMOVE) + @util.memoized_property + def _append_token(self): + return Event(self, OP_APPEND) + + @util.memoized_property + def _remove_token(self): + return Event(self, OP_REMOVE) def fire_append_event(self, state, dict_, value, initiator): for fn in self.dispatch.append: -- cgit v1.2.1