+ 3

How fast does numpy arrays perform any operation?

In the following code i am finding number of vowels using count method and numpy count non zero . What i would like to know is why there is such a huge difference in speed between both ? ty! https://code.sololearn.com/cKliZF6lrKQ1/?ref=app

6th Mar 2021, 5:40 PM
Abhay
Abhay - avatar
2 Respostas
+ 5
Numpy arrays are way faster than python built-in data types like list, because of several reasons. I'm pointing out some of the important ones: 1. Numpy array is highly compact than python list as list can have different data types inside them which basically reduces speed. 2. Numpy is implemented in highly optimized C code. 3. Numpy array uses vectorization by which it can make use of vector ALU rather than scalar ALU of the processor. And vector ALU is super fast in operations involving arrays
6th Mar 2021, 6:35 PM
Abir Hasan
Abir Hasan - avatar
0
Abir Hasan Thank you :)
6th Mar 2021, 8:20 PM
Abhay
Abhay - avatar