def remove_objects_unworthy_of_naming(events): new_events = list(events) side_effects = all_of_type(events, SideEffect) affected_objects = objects_affected_by_side_effects(side_effects) invoked_objects = objects_with_method_calls(events) + objects_with_attribute_references(events) for obj, usage_count in object_usage_counts(events): # ImmutableObjects don't need to be named, as their identity is # always unambiguous. if not isinstance(obj, ImmutableObject): # Anything mentioned more than once have to be named. if usage_count > 1: continue # Anything affected by side effects is also worth naming. if obj in affected_objects: continue # All user objects with method calls should also get names for # readability. if obj in invoked_objects: continue try: while True: new_events.remove(obj) except ValueError: pass # If the element wasn't on the timeline, even better. return new_events
def remove_objects_unworthy_of_naming(events): new_events = list(events) side_effects = all_of_type(events, SideEffect) affected_objects = objects_affected_by_side_effects(side_effects) invoked_objects = objects_with_method_calls(events) + objects_with_attribute_references(events) for obj, usage_count in object_usage_counts(events): # ImmutableObjects don't need to be named, as their identity is # always unambiguous. if not isinstance(obj, ImmutableObject): # Anything mentioned more than once have to be named. if usage_count > 1: continue # Anything affected by side effects is also worth naming. if obj in affected_objects: continue # All user objects with method calls should also get names for # readability. if obj in invoked_objects: continue try: while True: new_events.remove(obj) except ValueError: pass # If the element wasn't on the timeline, even better. return new_events
def objects_required_for(test_event, timestamp, execution_events): required_objects = [] required_side_effects = [] objects = resolve_dependencies(test_event) while objects: new_objects, new_side_effects = copy_events_over(objects, timestamp, execution_events) required_objects.extend(new_objects) required_side_effects.extend(new_side_effects) objects = list(new_only(objects_affected_by_side_effects(new_side_effects), required_objects)) return required_objects + required_side_effects
def objects_required_for(test_event, timestamp, execution_events): required_objects = [] required_side_effects = [] objects = resolve_dependencies(test_event) while objects: new_objects, new_side_effects = copy_events_over( objects, timestamp, execution_events) required_objects.extend(new_objects) required_side_effects.extend(new_side_effects) objects = list( new_only(objects_affected_by_side_effects(new_side_effects), required_objects)) return required_objects + required_side_effects
def side_effects_before_and_affected_objects(call): se = side_effects_before(call) return se + objects_affected_by_side_effects(se)
def side_effects_before_and_affected_objects(call): se = side_effects_before(call) return se + objects_affected_by_side_effects(se)