On Tue, Aug 26, 2014 at 6:11 AM, Andreas Lobinger <lobing...@gmail.com>
wrote:

> Oldschool julia users and developers have a tendency to discourage
> vectorized forms, but i'm still waiting for a convicing example to go for
> explicit loops in the general case.


No one is against vectorized code. Vectorized code is often the nicest way
to express things, but there are also cases where one is forced to write
vectorized code for performance in Python/Matlab/R, where for loops would
be clearer – and I think this is such a situation. For loops can be
recommended for two different (non-exclusive) reasons: clarity and speed.
In this particular case, I think the for loop version is clearer *and*
faster.

We do want to get to the point where vectorized code can be as efficient as
hand-fused for loops, but that's not easy to accomplish in general. Until
then, there are situations where you want to use for loops just for speed
even though the resulting code is not clearer. Such is life.

Reply via email to