+ 4

What is NumPy and how is it better than a list in Python?

2nd Dec 2017, 2:17 PM
ephy
ephy - avatar
3 Answers
+ 9
numpy is a Python module which mainly deals with its own datatype - numpy.array. The main difference is that all elements in an array must be of the same type, most often numerical. Arrays (or matrices) can then be mathematically transformed element-wise, using simplified equations, which speeds up those operations greatly over those you'd normally see being done with lists.
2nd Dec 2017, 2:27 PM
Kuba SiekierzyƄski
Kuba SiekierzyƄski - avatar
+ 7
I agree with Kuba and here some examples what you can do with numpy and reference website: https://docs.scipy.org/doc/numpy-1.13.0/reference/index.html https://code.sololearn.com/c9DZ7Kf65IR9/?ref=app
2nd Dec 2017, 5:07 PM
Ferhat Sevim
Ferhat Sevim - avatar
+ 4
Going by Kuba's definition (for anyone that may also be experienced in C++), using the NumPy module in Python is the same as including the <vector> library in C++ ... where arrays require each element to be of the same data-type & vectors (NumPy in Python) are much more dynamic, allowing you to improvise a lot more when iterating through dynamic lists or during certain computations. I'm not sure if they're so similar that their behaviors are the same ... because (if I remember correctly) vectors in C++ take up more memory than arrays while at the same time allowing much quicker executions on the vectors.. kind of like trading storage for speed, etc. Out of curiosity, does anyone know if NumPy is the same?
3rd Dec 2017, 3:02 AM
Fox
Fox - avatar