import time
import numpy as np
SIZE = 200000
list1 = range(SIZE)
list2 = range(SIZE)
arra1 = np.arange(SIZE)
arra2 = np.arange(SIZE)
start_list = time.time()
result=[(x,y) for x,y in zip(list1,list2)]
print("Time to aggregates elements from each of the iterables:")
print("List:")
print((time.time()-start_list)*1000)
start_array = time.time()
result = arra1 + arra2
print("NumPy array:")
print((time.time()-start_array)*1000)
Sample Output:
Time to aggregates elements from each of the iterables:
List:
72.64399528503418
NumPy array:
19.61684226989746
Sample Output:
need an explanation for this answer? contact us directly to get an explanation for this answer