import numpy as np
from collections import defaultdict, Counter
A_np = np.random.randint(0, 10 ** 4, 10 ** 6)
A_li = list(A_np)
%%timeit
d = defaultdict(int)
for a in A_li:
d[a] += 1
%%timeit
Counter(A_li)
%%timeit
np.unique(A_np, return_counts = True)
%%timeit
np.bincount(A_np)