I have lots of code of this kind

>>> e = d1.copy(); e.update(d2)

so the addition operator would be most welcome.  I congratulate to this PEP!

In fact, I would have wished, and in early programming had assumed, the `update` method would return the updated array rather than modifying the existing one, more along the philosophy of debugging-friendly functional programming.  (Some NumPy methods are also not quite consistently semantically transparent to me in that regard.)  An `dict.updated` method would have been a good explicit alternative, but with just the extra `d` at the end may be too error-prone.

Yes, overloading can be confusing unless one realises that it is just a short form of calling the `__add__` method in this case.  It is non-commutative for this operation, which can be a source of confusion for novices (same as multiplication for matrices, operators in QM, quaternions, ...) and, more trivially, similar to addition of ordered structures such as strings and lists whether not being commutative is obvious; just for unordered structures it is less obvious at first; dictionaries are different again.

over all: +1 

On Thu, 17 Oct 2019 at 16:37, Brandt Bucher <brandtbucher@gmail.com> wrote:
At long last, Steven D'Aprano and I have pushed a second draft of PEP 584 (dictionary addition):


The accompanying reference implementation is on GitHub:


This new draft incorporates much of the feedback that we received during the first round of debate here on python-ideas. Most notably, the difference operators (-/-=) have been dropped from the proposal, and the implementations have been updated to use "new = self.copy(); new.update(other)" semantics, rather than "new = type(self)(); new.update(self); new.update(other)" as proposed before. It also includes more background information and summaries of major objections (with rebuttals).

Please let us know what you think – we'd love to hear any *new* feedback that hasn't yet been addressed in the PEP or the related discussions it links to! We plan on updating the PEP at least once more before review.


Python-ideas mailing list -- python-ideas@python.org
To unsubscribe send an email to python-ideas-leave@python.org
Message archived at https://mail.python.org/archives/list/python-ideas@python.org/message/W2FCSC3JDA7NUBXAVSTVCUDEGAKWWPTH/
Code of Conduct: http://python.org/psf/codeofconduct/