[Numpy-discussion] Syntax Improvement for Array Transpose

Marten van Kerkwijk m.h.vankerkwijk at gmail.com
Wed Jun 26 16:24:14 EDT 2019


> The main motivation for the @ PEP was actually to be able to get rid of
> objects like np.matrix and scipy.sparse matrices that redefine the meaning
> of the * operator. Quote: "This PEP proposes the minimum effective change
> to Python syntax that will allow us to drain this swamp [meaning np.matrix
> & co]."
>
> Notably, the @ PEP was written by Nathaniel, who was opposed to a copying
> .H.
>

I should note that my comment invoking the history of @ was about the
regular transpose, .mT.  The executive summary of the PEP includes the
following relevant sentence:
"""
Currently, most numerical Python code uses * for elementwise
multiplication, and function/method syntax for matrix multiplication;
however, this leads to ugly and unreadable code in common circumstances.
"""

Exactly the same holds for matrix transpose, and indeed for many matrix
expressions the gain in readability is lost without a clean option to do
the transpose.

-- Marten
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/numpy-discussion/attachments/20190626/d602ba23/attachment.html>


More information about the NumPy-Discussion mailing list