actually, have you looked into scipy's hamming distance function?

http://docs.scipy.org/doc/scipy/reference/generated/scipy.spatial.distance.hamming.html