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

Antoine Pitrou solipsis at pitrou.net
Sat Mar 15 13:06:31 CET 2014


On Sun, 16 Mar 2014 00:55:09 +1300
Greg Ewing <greg.ewing at canterbury.ac.nz> wrote:
> Antoine Pitrou wrote:
> 
> > The possible reason given in the PEP is very weak and amounts to
> > premature optimization:
> 
> I don't think it's just a matter of optimization. Often,
> matrix @ vector represents a linear operator acting on an
> element of a vector space. When you chain them,
> 
>     A @ B @ C @ v
> 
> conceptually represents acting on v with C, then B,
> then A.

It can just as well represent "acting" on v with (A @ B @ C).

Of course, mathematically it shouldn't make a difference, but in
computer programming right-associative operators are always a special
case, and therefore an additional cognitive burden.

Regards

Antoine.




More information about the Python-ideas mailing list