Index: org/python/core/PyObject.java =================================================================== RCS file: /cvsroot/jython/jython/org/python/core/PyObject.java,v retrieving revision 2.30 diff -u -d -C4 -r2.30 PyObject.java *** org/python/core/PyObject.java 6 Aug 2003 11:46:26 -0000 2.30 --- org/python/core/PyObject.java 13 Dec 2003 19:13:50 -0000 *************** *** 1001,1069 **** else return new PyIdentityTuple(new PyObject[] { o, this }); } ! private final int _cmp_unsafe(PyObject o2_in) { ! // Shortcut for equal objects ! if (this == o2_in) ! return 0; ! PyObject o2 = o2_in; ! PyObject o1 = this; ! int itmp; ! Object ctmp; if (o1.__class__ != o2.__class__) { ! ctmp = o1.__coerce_ex__(o2); if (ctmp != null) { if (ctmp instanceof PyObject[]) { o1 = ((PyObject[])ctmp)[0]; o2 = ((PyObject[])ctmp)[1]; } else { o2 = (PyObject)ctmp; } - } - } - else ctmp = null; - if (ctmp != Py.None && (itmp = o1.__cmp__(o2)) != -2) - return itmp; ! o1 = this; ! o2 = o2_in; ! if (o1.__class__ != o2.__class__) { ! ctmp = o2.__coerce_ex__(o1); ! if (ctmp != null) { ! if (ctmp instanceof PyObject[]) { ! o2 = ((PyObject[])ctmp)[0]; ! o1 = ((PyObject[])ctmp)[1]; ! } ! else { ! o1 = (PyObject)ctmp; ! } } } - if (ctmp != Py.None && (itmp = o2.__cmp__(o1)) != -2) - return -itmp; ! if (this == o2_in) return 0; /* None is smaller than anything */ if (this == Py.None) return -1; ! if (o2_in == Py.None) return 1; // No rational way to compare these, so ask their classes to compare ! itmp = this.__class__.__cmp__(o2_in.__class__); if (itmp == 0) ! return System.identityHashCode(this) < ! System.identityHashCode(o2_in) ? -1 : 1; if (itmp != -2) return itmp; ! return System.identityHashCode(this.__class__) < ! System.identityHashCode(o2_in.__class__) ? -1 : 1; } private final static PyObject check_recursion(ThreadState ts, --- 1001,1064 ---- else return new PyIdentityTuple(new PyObject[] { o, this }); } ! private static final int _cmp_half(PyObject o1_in, PyObject o2_in) ! { ! PyObject o1 = o1_in; PyObject o2 = o2_in; ! if (o1.__class__ != o2.__class__) { ! Object ctmp = o1.__coerce_ex__(o2); ! if (ctmp == Py.None) ! return -2; if (ctmp != null) { if (ctmp instanceof PyObject[]) { o1 = ((PyObject[])ctmp)[0]; o2 = ((PyObject[])ctmp)[1]; } else { o2 = (PyObject)ctmp; } ! if (o1 != o1_in || o2 != o2_in) ! return o1._cmp(o2); } } ! return o1.__cmp__(o2); ! } ! ! private final int _cmp_unsafe(PyObject other) { ! // Shortcut for equal objects ! if (this == other) return 0; + int half = _cmp_half(this, other); + if (half != -2) + { + return half; + } + half = _cmp_half(other, this); + if (half != -2) + { + return -half; + } + /* None is smaller than anything */ if (this == Py.None) return -1; ! if (other == Py.None) return 1; // No rational way to compare these, so ask their classes to compare ! int itmp = this.__class__.__cmp__(other.__class__); if (itmp == 0) ! return Py.id(this) < Py.id(other) ? -1 : 1; if (itmp != -2) return itmp; ! return Py.id(this.__class__) < Py.id(other.__class__) ? -1 : 1; } private final static PyObject check_recursion(ThreadState ts,