def _cmp(self, other): # the bit sequence should be of the same length ld = len(self) - len(other) if ld: return ld for n, (x, y) in enumerate(zip(self._seq, other.sequence()), start=1): if xor(x, y): return n return 0