def __cmp(self, other): if isinstance(other, mpz): res = gmp.mpz_cmp(self._mpz, other._mpz) elif isinstance(other, (int, long)): if 0 <= other <= MAX_UI: res = gmp.mpz_cmp_ui(self._mpz, other) else: oth = _new_mpz() _pylong_to_mpz(other, oth) res = gmp.mpz_cmp(self._mpz, oth) _del_mpz(oth) elif isinstance(other, float): res = gmp.mpz_cmp_d(self._mpz, other) else: return None return res
def __nonzero__(self): return gmp.mpz_cmp_ui(self._mpz, 0) != 0