import cython @cython.total_ordering cdef class ExtGe: cdef int x def __ge__(self, other): if not isinstance(other, ExtGe): return NotImplemented return self.x >= (other).x def __eq__(self, other): return isinstance(other, ExtGe) and self.x == (other).x