bunch of optimizations to use vectorized np in match_hashes