Numpy array is more efficient than native python list. Run this example to see it for yourself how quick numpy array is when compared to native python list.
import numpy as np
import time
SIZE = 1000
l1 = range(SIZE)
l2 = range(SIZE)
a1 = np.arange(SIZE)
a2 = np.arange(SIZE)
t1 = time.time()
result1 = [(x+y) for x,y in zip(l1,l2)]
t2 = time.time()
print((t2-t1)*100000)
t1 = time.time()
result2 = a1+a2
t2 = time.time()
print((t2-t1)*100000)
Comments
Post a Comment