> I know, but if an element-wise operator is useful it would also be useful
> for libraries like NumPy that already support the @ operator for matrix
> multiplication.
>

A bit of history:

A fair amount of inspiration (or at least experience) for numpy came from
MATLAB.

MATLAB has essentially two complete sets of math operators: the regular
version, and the dot version.

A * B

Means matrix multiplication, and

A .* B

Means elementwise multiplication. And there is a full set of matrix and
elementwise operators.

Back in the day, Numeric (numpy’s predecessor”) used the math operators for
elementwise operations, and doing matrix math was unwieldy. There was a lit
of discussion and a number of proosals for s full set of additional
operators in python that could be used for matrix operations ( side note:
there was (is) a numpy.matrix class that defines __mul__ as matrix
multiplication).

Someone at some point realized that we didn’t need a full set, because
multiplication was really the only compelling use case. So the @ operator
was added.

End history.

Numpy, or course, is but one third party package, but it is an important
one — major inconsistency with it is a bad idea.

 -CHB

-- 
Christopher Barker, PhD

Python Language Consulting
  - Teaching
  - Scientific Software Development
  - Desktop GUI and Web Development
  - wxPython, numpy, scipy, Cython
_______________________________________________
Python-ideas mailing list
Python-ideas@python.org
https://mail.python.org/mailman/listinfo/python-ideas
Code of Conduct: http://python.org/psf/codeofconduct/

Reply via email to