Speedup cython dictionary counter
You don't give us much context for this problem, so it's unclear to me exactly what you are trying to achieve. But in your example, you have a pair of NumPy arrays containing integers in the range 0–2, and you seem to want to count the number of occurrences of each pair of values.

So I suggest encoding pairs of integers in the range 0–2 into a single integer in the range 0–8, using numpy.bincount to do the counting, and then using numpy.reshape to decode the result, like this:

&gt;&gt;&gt; import numpy as np
&gt;&gt;&gt; x, y = np.random.randint(0,3,200000), np.random.randint(0,3,200000)
&gt;&gt;&gt; counts = np.bincount(x * 3 + y).reshape((3, 3))
&gt;&gt;&gt; counts
array([[22282, 22093, 22247],
       [22084, 22295, 22396],
       [22012, 22243, 22348]])


A quick check that I got the encoding/decoding right:

&gt;&gt;&gt; counts[0,2] == np.count_nonzero((x == 0) &amp; (y == 2))
True


This runs much faster than the code in your question (assuming I have interpreted your profile screenshots correctly):

&gt;&gt;&gt; from timeit import timeit
&gt;&gt;&gt; timeit(lambda:np.bincount(x * 3 + y).reshape((3, 3)), number=1000)
2.7519797360000666