Skip to content

Rich Relations

The "rich" comparison special methods often return a bool. However, instances of any type can be returned (e.g. a numpy array). This is why the corresponding optype.Can* interfaces accept a second type argument for the return type, that defaults to bool when omitted. The first type parameter matches the passed method argument, i.e. the right-hand side operand, denoted here as x.

operator operand
expression reflected function type method type
_ == x x == _ do_eq DoesEq __eq__ CanEq[-T = object, +R = bool]
_ != x x != _ do_ne DoesNe __ne__ CanNe[-T = object, +R = bool]
_ < x x > _ do_lt DoesLt __lt__ CanLt[-T, +R = bool]
_ <= x x >= _ do_le DoesLe __le__ CanLe[-T, +R = bool]
_ > x x < _ do_gt DoesGt __gt__ CanGt[-T, +R = bool]
_ >= x x <= _ do_ge DoesGe __ge__ CanGe[-T, +R = bool]