r/ProgrammerAnimemes • • Aug 10 '19

Make your code Elegant

Post image
1.2k Upvotes

41 comments sorted by

View all comments

Show parent comment

2

u/Finianb1 Sep 24 '19

The numpy function is also going to be significantly faster, since it will either loop over the data in C instead of in Python, for faster looping.

If the input is in a numpy array, I believe it takes advantage of the number packing to use vector instructions in the CPU to speed it up even more. Nothing like a single SSE instruction to do a 4-wide vector addition in a single cycle.