public int __cmp__(PyObject other) { PyType self_type = getType(); PyObject[] where_type = new PyObject[1]; PyObject impl = self_type.lookup_where("__cmp__", where_type); // Full Compatibility with CPython __cmp__: // If the derived type don't override __cmp__, the // *internal* super().__cmp__ should be called, not the // exposed one. The difference is that the exposed __cmp__ // throws a TypeError if the argument is an instance of the same type. if (impl == null || where_type[0] == TYPE || Py.isSubClass(TYPE, where_type[0])) { return super.__cmp__(other); } PyObject res = impl.__get__(this, self_type).__call__(other); if (res == Py.NotImplemented) { return -2; } int c = res.asInt(); return c < 0 ? -1 : c > 0 ? 1 : 0; }