cut down method calls by about 9% in some circumstances.
[ticket:1932]
- scoped_session emits a warning when configure() is
called if a Session is already present (checks only the
current thread) [ticket:1924]
+
+ - reworked the internals of mapper.cascade_iterator() to
+ cut down method calls by about 9% in some circumstances.
+ [ticket:1932]
- sql
- Table.tometadata() now copies Index objects associated
mapper activity will not be performed.
"""
-
+
def instrument_class(self, mapper, class_):
"""Receive a class when the mapper is first constructed, and has
applied instrumentation to the mapped class.
attribute access, loading behavior, and dependency calculations.
"""
+ cascade = ()
+ """The set of 'cascade' attribute names.
+
+ This collection is checked before the 'cascade_iterator' method is called.
+
+ """
+
def setup(self, context, entity, path, adapter, **kwargs):
"""Called by Query for the purposes of constructing a SQL statement.
halt_on=None):
"""Iterate through instances related to the given instance for
a particular 'cascade', starting with this MapperProperty.
+
+ Return an iterator3-tuples (instance, mapper, state).
+
+ Note that the 'cascade' collection on this MapperProperty is
+ checked first for the given type before cascade_iterator is called.
See PropertyLoader for the related instance implementation.
"""
"""
visited_instances = util.IdentitySet()
- visitables = [(self._props.itervalues(), 'property', state)]
+ prp, mpp = object(), object()
+
+ visitables = [(deque(self._props.values()), prp, state)]
while visitables:
iterator, item_type, parent_state = visitables[-1]
- try:
- if item_type == 'property':
- prop = iterator.next()
- visitables.append(
- (prop.cascade_iterator(type_, parent_state,
- visited_instances, halt_on), 'mapper', None)
- )
- elif item_type == 'mapper':
- instance, instance_mapper, corresponding_state = \
- iterator.next()
- yield (instance, instance_mapper)
- visitables.append((instance_mapper._props.itervalues(),
- 'property', corresponding_state))
- except StopIteration:
+ if not iterator:
visitables.pop()
+ continue
+
+ if item_type is prp:
+ prop = iterator.popleft()
+ if type_ not in prop.cascade:
+ continue
+ queue = deque(prop.cascade_iterator(type_, parent_state,
+ visited_instances, halt_on))
+ if queue:
+ visitables.append((queue,mpp, None))
+ elif item_type is mpp:
+ instance, instance_mapper, corresponding_state = \
+ iterator.popleft()
+ yield (instance, instance_mapper)
+ visitables.append((deque(instance_mapper._props.values()),
+ prp, corresponding_state))
@_memoized_compiled_property
def _compiled_cache(self):
# cascade using the mapper local to this
# object, so that its individual properties are located
instance_mapper = instance_state.manager.mapper
- yield (c, instance_mapper, instance_state)
+ yield c, instance_mapper, instance_state
+
def _add_reverse_property(self, key):
other = self.mapper.get_property(key, _compile_mappers=False)
def test_profile_1_create_tables(self):
self.test_baseline_1_create_tables()
- @profiling.function_call_count(9225)
+ @profiling.function_call_count(8469)
def test_profile_1a_populate(self):
self.test_baseline_1a_populate()
- @profiling.function_call_count(640)
+ @profiling.function_call_count(591)
def test_profile_2_insert(self):
self.test_baseline_2_insert()