This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author scoder
Recipients brandtbucher, gvanrossum, rhettinger, scoder, serhiy.storchaka, xtreak
Date 2019-02-28.09:20:07
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <>
> We already have a syntax for dict merging: {**d1, **d2}. 

Which doesn't mean that "d1 + d2" isn't much more intuitive than this special-character heavy version. It takes me a while to see the dict merge under that heap of stars. And that's already the shortest example.

> It works with arbitrary mappings,

The RHS of "d += M" doesn't have to be a dict IMHO, it could be any mapping. And even "dict(X) + M" doesn't look all too bad to me, even though there's "dict(X, **M)".

> Use of the + operator is a temptation to produce new dictionaries rather than update an existing dict in-place which is usually what you want.

That's why there would be support for "+=". The exact same argument already fails for lists, where concatenation is usually much more performance critical than for the average little dict. (And remember that most code isn't performance critical at all.)

> We already have ChainMap() which presents a single view of multiple mappings with any copying.

Which is a different use case that is unlikely to go away with this proposal.

> makes it less clear that you're working with dicts.

This is a valid argument, although it always depends on the concrete code what the most readable way to express its intentions is. Again, this doesn't really differ for lists.

Let's wait for the PEP, I'd say.
Date User Action Args
2019-02-28 09:20:07scodersetrecipients: + scoder, gvanrossum, rhettinger, serhiy.storchaka, xtreak, brandtbucher
2019-02-28 09:20:07scodersetmessageid: <>
2019-02-28 09:20:07scoderlinkissue36144 messages
2019-02-28 09:20:07scodercreate