[Python-ideas] Dict joining using + and +=

David Mertz mertz at gnosis.cx
Mon Mar 4 09:42:53 EST 2019

On Mon, Mar 4, 2019, 8:30 AM Serhiy Storchaka <storchaka at gmail.com> wrote:

> But is merging two dicts a common enough problem that needs introducing
> an operator to solve it? I need to merge dicts maybe not more than one
> or two times by year, and I am fine with using the update() method.
> Perhaps {**d1, **d2} can be more appropriate in some cases, but I did not
> encounter such cases yet.

Like other folks in the thread, I also want to merge dicts three times per
year. And every one of those times, itertools.ChainMap is the right way to
do that non-destructively, and without copying.

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-ideas/attachments/20190304/19a32612/attachment.html>

More information about the Python-ideas mailing list