Traffy.UnityPython
Traffy.UnityPython copied to clipboard
PEP 0207
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.
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.