-
Notifications
You must be signed in to change notification settings - Fork 100
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
ListConfig append deepcopies input config nodes #738
Conversation
The |
This is an optimization, so not super critical because ListConfigs are not common. |
I commented out the edge-case logic to see what test would fail. The following case from input1 = {"n": {"a": 10}, "i": "${n}"}
input2 = {"i": {"b": 20}}
expected = {"n": {"a": 10}, "i": {"a": 10, "b": 20}}
# the below succeeds
assert expected == OmegaConf.merge(input1, input2)
# the below fails: unsafe_merge returns {'n': {'a': 10, 'b': 20}, 'i': {'a': 10, 'b': 20}}
assert expected == OmegaConf.unsafe_merge(input1, input2) It seems that this edge case only happens when merging into an interpolation; the deepcopy prevents the merge from mutating other parts of the tree. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I guess I'm a few minutes late on the review, sorry. Feel free to ignore my minor comment below.
At high level I'm fine with it but I wonder if append()
wouldn't be better implemented as "append None
to the underlying content list, then call set_item()
on the last index". There's more stuff happening in _set_item_impl()
that I don't fully grasp, which may -- or may not -- matter as well for append()
.
@@ -0,0 +1 @@ | |||
ListConfig append now copies input config nodes |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Easier to read (at least to me):
ListConfig append now copies input config nodes | |
ListConfig.append now copies input config nodes |
Good call. |
Closes #601
Not worried about perf:
This is something we are already doing for DictConfig, and ListConfig is not used nearly as much.