python numpy || numpy || why numpy || series
numpy download python numpy tutorial how to install numpy numpy documentation numpy python 3 numpy documentation pdf numpy functions numpy array ------------------------------------------------------------------------------------------------------------------------------------------------ import time import numpy as np size_of_vec = 1000 def pure_python_version(): t1 = time.time() X = range(size_of_vec) Y = range(size_of_vec) Z = [X[i] + Y[i] for i in range(len(X)) ] return time.time() - t1 def numpy_version(): t1 = time.time() X = np.arange(size_of_vec) Y = np.arange(size_of_vec) Z = X + Y return time.time() - t1 t1 = pure_python_version() t2 = numpy_version() print(t1, t2) print("Numpy is in this example " + str(t1/t2) + " faster!") -------------------------------------------------------------------------------------------------------------------------------------------------- import numpy as np import time import sys # let's declare the size Size = 100000 # Creating two lists list1 = range(Size) list2 = range(Size) # Creating two NumPy arrays arr1 = np.arange(Size) arr2 = np.arange(Size) # Calculating time for Python list start = time.time() result = [(x ,y) for x, y in zip(list1, list2)] print("Time for Python List in msec: ", (time.time() - start) * 1000) # Calculating time for NumPy array start = time.time() result = arr1 ,arr2 print("Time for NumPy array in msec: ", (time.time()- start) * 1000) print("\nThis means NumPy array is faster than Python List") -------------------------------------------------------------------------------------------------------------------------------- thanks ************************************************************************************** please subscribe like share with your friends **************************************************************************************
Download
0 formatsNo download links available.