From 79c28038a5a150edea9f1d4977d0f494a61ab5ce Mon Sep 17 00:00:00 2001 From: Emmanuel Garette Date: Mon, 25 Jun 2018 22:20:24 +0200 Subject: [PATCH] better performance in optiondescription creation --- tiramisu/option/baseoption.py | 9 ++------- tiramisu/option/optiondescription.py | 21 ++++++++++++++++----- 2 files changed, 18 insertions(+), 12 deletions(-) diff --git a/tiramisu/option/baseoption.py b/tiramisu/option/baseoption.py index 0135ef9..ffdb935 100644 --- a/tiramisu/option/baseoption.py +++ b/tiramisu/option/baseoption.py @@ -275,15 +275,10 @@ class Base(object): self._val_call = (val, val_call) def impl_is_optiondescription(self): - #FIXME deplacer dans OpenDescription ? - return self.__class__.__name__ in ['OptionDescription', - 'DynOptionDescription', - 'SynDynOptionDescription', - 'MasterSlaves'] + return False def impl_is_dynoptiondescription(self): - return self.__class__.__name__ in ['DynOptionDescription', - 'SynDynOptionDescription'] + return False def impl_getname(self): return self._name diff --git a/tiramisu/option/optiondescription.py b/tiramisu/option/optiondescription.py index 758af28..f0f18c9 100644 --- a/tiramisu/option/optiondescription.py +++ b/tiramisu/option/optiondescription.py @@ -393,11 +393,12 @@ class OptionDescription(OptionDescriptionWalk): if child.impl_is_dynoptiondescription(): dynopt_names.append(name) - #better performance like this - valid_child = copy(child_names) - valid_child.sort() + children_ = (tuple(child_names), tuple(children)) + + # better performance like this + child_names.sort() old = None - for child in valid_child: + for child in child_names: if child == old: raise ConflictError(_('duplicate option name: ' '"{0}"').format(child)) @@ -407,11 +408,21 @@ class OptionDescription(OptionDescriptionWalk): raise ConflictError(_('the option\'s name "{}" start as ' 'the dynoptiondescription\'s name "{}"').format(child, dynopt)) old = child - self._children = (tuple(child_names), tuple(children)) + self._children = children_ self._cache_consistencies = None # the group_type is useful for filtering OptionDescriptions in a config self._group_type = groups.default + def impl_is_optiondescription(self): + return self.__class__.__name__ in ['OptionDescription', + 'DynOptionDescription', + 'SynDynOptionDescription', + 'MasterSlaves'] + + def impl_is_dynoptiondescription(self): + return self.__class__.__name__ in ['DynOptionDescription', + 'SynDynOptionDescription'] + def impl_is_master_slaves(self, *args, **kwargs): return False