Skip to content

Avoid reparsing in EasyConfig.copy #5011

@Flamefire

Description

@Flamefire

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions