
Oct. 21, 2019
11:47 p.m.
Meitham Jamaa wrote:
The fact dict is a mutable object makes this PEP very complicated. Let's say we have this example: x = {'a': 1, 'b': 2, 'c': {'c': 3}} y = {'d': 4, 'c': {'c': 5}} If we were to merge the two dicts together, such as: x.update(y) Then we expect y to have been updated and look like: {'a': 1, 'b': 2, 'c': {'c': 5}, 'd': 4} x['c'] is now the same object of y['c'] and any updates to either is reflected on the other.
I really don't see how this is any different than list concatenation with +/+=... x = [1, 2] y = [{'c': 3}] x += y x[-1] and y[-1] now refer to the same object, and any updates in one will be reflected in the other. It would be surprising if they didn't!