-
Notifications
You must be signed in to change notification settings - Fork 1.5k
ConfigParser doesn't need deepcopy #6463
Copy link
Copy link
Closed
Description
Is your feature request related to a problem? Please describe.
In the current implementation, ConfigParser executes deepcopy for every config item when recursively parse the whole config:
MONAI/monai/bundle/config_parser.py
Line 379 in 8e8dd1b
| item_conf = deepcopy(config) |
But actually, all the parsing logic just read the config item content and generate a new config object:
MONAI/monai/bundle/reference_resolver.py
Line 295 in 8e8dd1b
| ret = type(config)() |
So I would suggest to remove this
deepcopy logic, it can bring 3 benefits:
- If use python object in the config dict,
deepcopyit may causeInvertdfailure due to mismatch object ID. - If the config structure contains very big python object (like CacheDataset), it will increase memory usage, especially considering it's a recursive operation.
- Some python objects may not support pickle operation and deepcopy will fail.
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels