[Python-ideas] The $update operator for dictionaries

James Lu jamtlu at gmail.com
Sun Mar 10 22:36:24 EDT 2019

This is a horrible idea.

I proposed to Mr. Fine earlier that we adopt a << operator.

d1 << d2 merges d2 into a copy of d1 and returns it, with keys from d2
overriding keys from d2.

On Sat, Mar 9, 2019 at 4:50 PM Jonathan Fine <jfine2358 at gmail.com> wrote:

> A good starting point for discussing the main idea is:
> PEP 465 -- A dedicated infix operator for matrix multiplication
> https://www.python.org/dev/peps/pep-0465
> Matrix multiplication is one of many special binary mathematical
> operators. PEP 465 successfully argues the merits of introducing a
> special operator for matrix multiplication. This thread starts from a
> discussion of the merits of binding dict.update to an operator. (For
> update, '+', '|' and '<<' the leading candidate symbols.)
> Matrices and linear algebra are not the only part of mathematics that
> is usually expressed with infix operators. Thus, I suggest that the
> main questions are:
> 1. In practice, how important are additional infix operators to the
> Python community?
> 2. Can we harmoniously extend Python to accommodate these new operators?
> Here, from PEP 465, are some highlights of the benefits.
> <quote>
> Infix @ dramatically improves matrix code usability at all stages of
> programmer interaction.
> A large proportion of scientific code is written by people who are
> experts in their domain, but are not experts in programming.
> For these kinds of users, whose programming knowledge is fragile, the
> existence of a transparent mapping between formulas and code often
> means the difference between succeeding and failing to write that code
> at all.
> </endquote>
> Most mathematical and scientific formulas can be written in LaTeX
> notation, which gives standard names for the infix operators
> mathematicians use.
> There is no transparent and obvious mapping from the present operators
> to those used in mathematics.
> https://docs.python.org/3/reference/lexical_analysis.html?#operators
> Using Unicode symbols for the math operators is probably unwise.
> Better, I suggest, is to use the LaTeX names.
> There is some evidence (the wish to bind dict.update to an infix
> operator) that outside of mathematics there is a demand for custom
> infix operators.
> --
> Jonathan
> _______________________________________________
> Python-ideas mailing list
> Python-ideas at python.org
> https://mail.python.org/mailman/listinfo/python-ideas
> Code of Conduct: http://python.org/psf/codeofconduct/
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-ideas/attachments/20190310/374768af/attachment-0001.html>

More information about the Python-ideas mailing list