[Python-ideas] Vectorization [was Re: Add list.join() please]

Ronald Oussoren ronaldoussoren at mac.com
Sun Feb 3 16:27:21 EST 2019


> On 3 Feb 2019, at 21:34, David Mertz <mertz at gnosis.cx> wrote:
> 
> On Sun, Feb 3, 2019 at 3:16 PM Ronald Oussoren <ronaldoussoren at mac.com <mailto:ronaldoussoren at mac.com>> wrote:
> The @ operator is meant for matrix multiplication (see PEP 465) and is already used for that in NumPy. IMHO just that is a good enough reason for not using @ as an elementwise application operator (ignoring if having an such an operator is a good idea in the first place).
> 
> Co-opting operators is pretty common in Python.  For example, the `.__div__()` operator spelled '/' is most often used for some kind of numeric division.  Some variations on that, for example vectorized in NumPy.  And different numeric types operate a bit differently.  The name of the magic method obvious suggests division.

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.  Using @ both for matrix multiplication and element-wise application could be made to work, but would be very confusing. 
 
Ronald

—

Twitter: @ronaldoussoren
Blog: https://blog.ronaldoussoren.net/
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-ideas/attachments/20190203/c420b9b3/attachment.html>


More information about the Python-ideas mailing list