workaround for pypy dtype hash

[Upstream issue](https://bitbucket.org/pypy/pypy/issue/1772/complex-dtype-unhashable)

This patch should workaround the problem without affecting the performance of the original version. I am using `json` because this is the most reliable way I can find to turn a dtype to a hashable object....