Hacker News new | ask | show | jobs
by lordgrenville 2156 days ago
It isn't just notation, though. It's a different way of operating. For example, the following adaptation of your code:

    c = 0
    for i in range(u.size):
        if u[i] < u[i + 1]:
            c = c + u[i] * v[i]
        else:
            c = 0
cannot be vectorised (ignoring the off-by-one error for simplicity's sake).

Saying that the Python interpreter should reinterpret the iterative code as if it were vectorised isn't increasing the expressivity, it's reducing it, by overriding the user's intentions.

1 comments

My point exactly! If I need to implement your algorithm in Python, why am I condemned to be hopelessly slow? Or worse, condemned to find a "trick" that vectorizes this code while it becomes unreadable?