[Python-ideas] PEP: Dict addition and subtraction

Christopher Barker pythonchb at gmail.com
Wed Mar 20 21:46:24 EDT 2019


On Sat, Mar 16, 2019 at 12:39 AM Antoine Pitrou <solipsis at pitrou.net> wrote:

> On Sat, 16 Mar 2019 01:41:59 +1100
> Steven D'Aprano <steve at pearwood.info> wrote:
>


> > Matrix multiplication is a perfect example: adding the @ operator could
> > have been done in Python 0.1 if anyone had thought of it, but it took 15
> > years of numerical folk "whinging" about the lack until it happened:
>
> Not so perfect, as the growing use of Python for scientific computing
> has made it much more useful to promote a dedicated matrix
> multiplication operator than, say, 15 or 20 years ago.
>

Theres more to it than that, really, but not really relevant here...


> This is precisely why I worded my question this way: what has changed
> in the last 20 years that make a "+" dict operator more compelling
> today than it was?  Do we merge dicts much more frequently than we
> did?


The analogy doesn't hold because @ was a new operator -- a MUCH bigger
change than dimply defining the use of + (or | ) for dicts.

I wouldn't mind the new operator if its meaning was clear-cut.  But
> here we have potential for confusion, both for writers and readers of
> code.
>

but it's NOT a new operator, it is making use of an existing one, and sure
you could guess at a couple meanings, but the merge one is probably one of
the most obvious to guess, and one quick test and you know -- I really
can't see it being a ongoing source of confusion.

-CHB

-- 
Christopher Barker, PhD

Python Language Consulting
  - Teaching
  - Scientific Software Development
  - Desktop GUI and Web Development
  - wxPython, numpy, scipy, Cython
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-ideas/attachments/20190320/a975f36e/attachment.html>


More information about the Python-ideas mailing list