|
|
|
|
|
by enriquto
2157 days ago
|
|
It would be nice to have an equivalent post, but with programming languages. The fact that different programs perform an identical computation is important. For example, in Python/numpy you can write c = 0
for i in range(u.size):
c = c + u[i] * v[i]
or c = u.T @ v
and even if the result is identical, the computation is not, the first one being orders of magnitude slower. There is no good reason for it to be so, unfortunately. |
|
- As a regular array (for someone with Python experience but no knowledge of linear algebra). In this case you can just loop over it as with any iterable.
- As a vector, with the associated mathematical properties. In this case you can operate on the entire vector, which is much faster; this happens to be because of implementation details (using C structures instead of Python lists, parallelisation, whatever), but is also just highly intuitive.
I'd argue that this is exactly what Tao is saying, about how different notations suit different contexts, and that allowing both methods in no way violates the Zen of Python (in reference to jimhefferon's comment).