Non-recursive, 8-bit block table lookup version: def ham(a, b, ht=[hamdist(a,0) for a in range(256)]): x = a ^ b dist = 0 while x: dist += ht[x & 255] x >>= 8 return dist Raymond