[Python-ideas] [RFC] draft PEP: Dedicated infix operators for matrix multiplication and matrix power

Antoine Pitrou solipsis at pitrou.net
Fri Mar 14 11:24:26 CET 2014


Hi,

On Fri, 14 Mar 2014 01:59:14 +0000
Nathaniel Smith <njs at pobox.com> wrote:
> 
> PEP 211, which instead adds an operator for itertools.product, aka,
> "maybe we can sneak matrix multiply past Guido in some sort of...
> large, wooden rabbit..."

A chocolate rabbit might be tastier for some core developers ;-)

Ok, so first I'm gonna state upfront that I don't have any personal
interest in this proposal (i.e. I don't do matrix multiplications often
enough for it to matter to me). That said:

> This PEP proposes two new binary operators dedicated to matrix
> multiplication and matrix power, spelled ``@`` and ``@@``
> respectively.  (Mnemonic: ``@`` is ``*`` for mATrices.)

That sounds like a strange choice to me. There's nothing in "@" or "@@"
that suggests "matrices" or "multiplication". Also, are there
precedents in other languages?

AFAIK, other languages sometimes use ".*" for matrix multiplication (as
opposed to element-wise multiplication). Why not re-use that
convention? Would that lead to parsing difficulties?

That said, I'm rather sympathetic to the general idea, and if "@" is
the least contentious option, then I'm ok with it too ("@@" doesn't
sound like a good idea at all, though).

Thanks for writing this PEP!

Regards

Antoine.




More information about the Python-ideas mailing list