Currently calling ec.copy() (as done e.g. by the Bundle and Extension easyblocks) involves calling the "default" __init__ function which does another parse call.
This will also call the parse hook which might lead to unexpected results.
In general it is unnecessarily slow.
In general we want newec.attr = deepcopy(self.attr) for each attr in the easyconfig. That could be a manual list risking it goes out of sync with those set in the __init__ call or iterate over dir(self) to get everything
2 approaches:
- Do a deep copy of the full contents of the easyconfig instance, this could require some customization via
__deep_copy__ but should be the most complete. In the end ec.copy() callers might reasonably expect to get an exact copy of the current state of the easyconfig.
- Store the name of the attributes set at the end of the EasyConfig
__init__ call. In the copy method iterate over those and do a deepcopy of their current values
Currently calling
ec.copy()(as done e.g. by the Bundle and Extension easyblocks) involves calling the "default"__init__function which does anotherparsecall.This will also call the parse hook which might lead to unexpected results.
In general it is unnecessarily slow.
In general we want
newec.attr = deepcopy(self.attr)for eachattrin the easyconfig. That could be a manual list risking it goes out of sync with those set in the__init__call or iterate overdir(self)to get everything2 approaches:
__deep_copy__but should be the most complete. In the endec.copy()callers might reasonably expect to get an exact copy of the current state of the easyconfig.__init__call. In thecopymethod iterate over those and do a deepcopy of their current values