summaryrefslogtreecommitdiff
path: root/docs/examples/userguide/special_methods/total_ordering.pyx
blob: 06d2ccef7afc0873dc52a53918ccf18e81954fd6 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
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 >= (<ExtGe>other).x

    def __eq__(self, other):
        return isinstance(other, ExtGe) and self.x == (<ExtGe>other).x