Open with one click!
In [1]:
import matplotlib.pyplot as plt %matplotlib inline import operator import numpy as np N = int(10e6) array_list = range(N) array_np = np.arange(N) times_list = { 'loop': 339, 'sum': 67, 'np.sum-': 427, 'reduce': 358 } times_np = { 'sum': 754, 'loop':1130, 'np.sum': 6, 'reduce': 1010 } plt.bar(np.arange(len(times_list)),times_list.values()) plt.xticks( np.arange(len(times_list)),times_list.keys()) plt.ylim(0,1200) plt.title('Times, list') plt.show() plt.bar(np.arange(len(times_np)),times_np.values()) plt.xticks( np.arange(len(times_np)),times_np.keys()) plt.ylim(0,1200) plt.title('Times, np.array') plt.show()
In [ ]: