Open thautwarm opened 2 years ago
Enhancement: The follow code illustrates a most efficient interface for structural ordering. We can provide a builtin abstract class, which asks the user to provide __eq__
and one of __fast_le__(other: _T , x: ref[bool])
and __fast_le__(other: _T , x: ref[bool])
, for fast structural ordering..
public interface IFastOrder<T>
{
public bool __le__(T other, ref bool isEqual);
public bool __ge__(T other, ref bool isEqual);
}
Done, but so far comparisons must return boolean or a type error is thrown. This is because in Unity broadcast comparisons are not widely used. Returning bool is faster.
https://www.python.org/dev/peps/pep-0207/
But still we want to skip tedious tasks when implementing the whole system.
Plan: learn from CPython impl: builtin classes use
__cmp__
, and__eq__
,__lt__
stuffs are generated.