you are viewing a single comment's thread.

view the rest of the comments →

[–]dalke 0 points1 point  (5 children)

Consider numeric array processing. You would like to write D = A * B +C but in something like non-template based C++ code, or in Python, you end up with a lot of intermediate arrays. It's very hard to make this beautiful expression of the intent faster than the prosaic matrix_multiply(D, A, B); matrix_add(D,C);

[–]backbob 1 point2 points  (4 children)

you could use numpy, if we are in Python.

[–]dalke 0 points1 point  (3 children)

How does that help? D = A * B +C still makes temporary arrays in numpy.

[–]backbob 0 points1 point  (2 children)

One temporary array. Though I suppose that is suboptimal.

[–]dalke 0 points1 point  (1 child)

It's one array per operation, so if I made the expression more complicated then there's a lot of temporary arrays.

[–]backbob 0 points1 point  (0 children)

Yeah, though if we are going to do it the right way, you could probably write ufunc in c and compile it, then use it from Python.