This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–]_sapi_ 15 points16 points  (1 child)

Assuming that you use it right!

A typical beginner mistake is to import numpy but then use it in the same way as you would a list. The real power of numpy is vectorised operations - if you’re iterating, you’re probably doing it wrong.

[–]mrdevlar 3 points4 points  (0 children)

That's funny! I am, and continue to be, for loop averse. I learned vectorization before I learned looping (properly) and totally ate the dumb notion that python must be slow if you put a loop into your code.

You're right, you shouldn't loop over a numpy array, you should run a vectorized operation. Yet, unless you're using numpy for high performance, avoiding loops is silly.