[ Numpy 100제 ] 41 ~ 50 번
41. How to sum a small array faster than np.sum? (★★☆) Z = np.arange(10) np.add.reduce(Z) # test for np.add.reduce import time def check_time(func): def wrapper(*args, **kwargs): start = time.time() func(*args, **kwargs) print("used time:", time.time() - start) return wrapper @check_time def normal_sum(len_array): a = np.arange(len_array) np.sum(a) @check_time def reduced_sum(len_array): a = np...
Python/Numpy
2022. 1. 30. 16:25