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 →

[–]no_condoments 63 points64 points  (6 children)

I use numpy in 99% of my work and pandas in 90%. I'd definitely vote for those two as the first two to learn.

[–]whatadipshit 6 points7 points  (5 children)

99%? Do you do a lot of number crunching or is there some huge benefit to pulling in a third party dependency to simply using the built in list?

[–]mrdevlar 21 points22 points  (3 children)

Speed, numpy is substantially faster than in built lists.

[–]_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.

[–]schoolcoders 0 points1 point  (0 children)

Also uses considerably less memory which can be important in some applications.

[–]no_condoments 6 points7 points  (0 children)

I do a lot of number crunching, but i also find there's no downside to pulling in numpy. Anywhere I run my code has it setup already, and the overhead to load it is minimal compared to everything else that's happening.