[Python-3000] Total ordering and cmp (original) (raw)
Guido van Rossum guido at python.org
Wed Mar 21 03:46:28 CET 2007
- Previous message: [Python-3000] Total ordering and __cmp__
- Next message: [Python-3000] Total ordering and __cmp__
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
But can this work? It might end up calling cmp() on two incomparable objects. For lt etc. that might be the right answer, but for eq it is not -- the default eq and ne must compare object identity.
(What is this __cmp you refer to? A typo for cmp or for cmp?)
--Guido
On 3/20/07, Terry Reedy <tjreedy at udel.edu> wrote:
"Collin Winter" <collinw at gmail.com> wrote in message news:43aa6ff70703201810p9d731b8v3497a48539d5dc84 at mail.gmail.com... | Quoting from the commit message for r51533, which removed the default ordering: | | What's the status on this? FWIW, I would like to see cmp stay as a | fallback measure if eq, ne, lt, etc aren't defined for | total ordering purposes. I've run across this while trying to get the | docs toolchain working, and I was initially shocked that cmp was | no longer called. An alternative would be to give the object class comparison methods defined _in terms of a missing cmp() method. _def eq(self,other): return cmp(self,other) == 0 # etc This would put the fallback to and conversion of cmp -1,0,1 output in one place instead of sprinkled everywhere. Or these could go into a cmporder mixin put in some lib module. Terry Jan Reedy
Python-3000 mailing list Python-3000 at python.org http://mail.python.org/mailman/listinfo/python-3000 Unsubscribe: http://mail.python.org/mailman/options/python-3000/guido%40python.org
-- --Guido van Rossum (home page: http://www.python.org/~guido/)
- Previous message: [Python-3000] Total ordering and __cmp__
- Next message: [Python-3000] Total ordering and __cmp__
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]