37
NumPy - Introduction
NumPy is the fundamental package for scientific computing in Python. It is a Python library that provides a multidimensional array object, various derived objects (such as masked arrays and matrices), and an assortment of routines for fast operations on arrays, including mathematical, logical, shape manipulation, sorting, selecting, I/O, discrete Fourier transforms, basic linear algebra, basic statistical operations, random simulation and much more.
So basically its an array
Open terminal and simply type
pip install numpy
If it doesn't work for you use
pip3 install numpy
Lets take an example
import time
start = time.time()
a = range(1000000)
for _ in range(10):
[x * 2 for x in a]
end = time.time()
print(f"Code executed in {(end-start)*1000} ms")
Code executed in 950.7663249969482 ms
import numpy as np
import time
start = time.time()
arr = np.arange(1000000)
for _ in range(10):
arr * 2
end = time.time()
print(f"Code executed in {(end-start)*1000} ms")
Code executed in 15.02847671508789 ms

37