top | item 7961121

(no title)

fddr | 11 years ago

> It’s not really a feature, it’s an operator that can be overloaded. That is, instead of using `mymodule.dot(a, b)`, you can use the much less readable `a @ b`.

I disagree with you, and think it's definitely a feature. If you are doing scientific computing it can be much more readable to use infix overloaded operators. What is better, `np.dot(x.T(), np.dot(M, x))` or `x.T() @ M @ x`? I find the second much more readable.

I get it that operator overloading can be abused and lead to unreadable code, but in some use cases it is a godsend.

discuss

order

hk__2|11 years ago

That’s true, but you already can overload other operators like __mul__ to have `x.T() * M * x`.

dagw|11 years ago

__mul__ has been used for elementwise multiplication in numerical python for the past 18 years or so. You can argue if it was a good choice or not, but it's a bit too entrenched to change now.