More damage to intuition (was RE: [Python-Dev] Comparison of recursive objects)
Guido van Rossum
Mon, 22 Jan 2001 11:02:15 -0500
> > My only concern is that under the old schele, two different numeric
> > extension types that somehow can't be compared will end up being
> > *equal*. To fix this, I propose that if the names compare equal, as a
> > last resort we compare the type pointers -- this should be consistent
> > too.
> Agreed, and sounds fine!
Checked in now.
While fixing the test_b1 code again, which depends on this behavior, I
thought of a refinement: it wouldn't be hard to make None compare
smaller than *anything* (including numbers).
Is this worth it?
diff -c -r2.113 object.c
*** object.c 2001/01/22 15:59:32 2.113
--- object.c 2001/01/22 16:03:38
*** 550,555 ****
--- 550,561 ----
+ /* None is smaller than anything */
+ if (v == Py_None)
+ return -1;
+ if (w == Py_None)
+ return 1;
/* different type: compare type names */
vname = "";
--Guido van Rossum (home page: http://www.python.org/~guido/)