[SciPy-Dev] A PEP for adding infix matrix multiply to Python

Nathaniel Smith njs at pobox.com
Sat Feb 22 17:00:47 EST 2014


[Apologies for wide distribution -- please direct followups to either
the github PR linked below, or else numpy-discussion at scipy.org]

After the numpy-discussion thread about np.matrix a week or so back, I
got curious and read the old PEPs that attempted to add better
matrix/elementwise operators to Python.
  http://legacy.python.org/dev/peps/pep-0211/
  http://legacy.python.org/dev/peps/pep-0225/
And I was a bit surprised -- if I were BDFL I probably would have
rejected these PEPs too. One is actually a proposal to make
itertools.product into an infix operator, which no-one would consider
seriously on its own merits. And the other adds a whole pile of
weirdly spelled new operators with no clear idea about what they
should do.

But it seems to me that at this point, with the benefit of multiple
years more experience, we know much better what we want -- basically,
just a nice clean infix op for matrix multiplication. And that just
asking for this directly, and explaining clearly why we want it, is
something that hasn't been tried. So maybe we should try and see what
happens.

As a starting point for discussion, I wrote a draft. It can be read
and commented on here:
   https://github.com/numpy/numpy/pull/4351

It's important that if we're going to do this at all, we do it right,
and that means being able to honestly say that this document
represents our consensus when going to python-dev. So if you think you
might object please do so now :-)

-n

-- 
Nathaniel J. Smith
Postdoctoral researcher - Informatics - University of Edinburgh
http://vorpus.org



More information about the SciPy-Dev mailing list