I'll regret jumping in here, but while dict(A, **B) as a way to merge two dicts A and B makes some sense, it has two drawbacks: (1) slow (creates an extra copy of B as it creates the keyword args structure for dict()) and (2) not general enough (doesn't support key types other than str).


On Mon, Jul 28, 2014 at 7:59 AM, Steven D'Aprano <steve@pearwood.info> wrote:
On Mon, Jul 28, 2014 at 06:26:13AM +0100, Joshua Landau wrote:
> On 27 July 2014 02:17, Steven D'Aprano <steve@pearwood.info> wrote:
[...]
> > Is there a good reason for implementing the + operator as
> > dict.update?
>
> One good reason is that people are still convinced "dict(A, **B)"
> makes some kind of sense.

Explain please. dict(A, **B) makes perfect sense to me, and it works
perfectly too. It's a normal constructor call, using the same syntax as
any other function or method call. Are you suggesting that it does not
make sense?


--
Steven
_______________________________________________
Python-ideas mailing list
Python-ideas@python.org
https://mail.python.org/mailman/listinfo/python-ideas
Code of Conduct: http://python.org/psf/codeofconduct/



--
--Guido van Rossum (python.org/~guido)