Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # Write your code here
- x =np.array(np.random.random(10000000))
- start_time = time.time()
- sum_loop = 0
- for i in range (len(x)):
- sum_loop += x[i]
- print (sum_loop)
- print("--- %s seconds ---" % (time.time() - start_time))
- start_time = time.time()
- sum_Numpy = np.sum(x)
- print (sum_Numpy)
- print("--- %s seconds ---" % (time.time() - start_time))
- print("^ that is indeed faster")
- start_time = time.time()
- print(sum(x))
- print("--- %s seconds ---" % (time.time() - start_time))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement