On 2/17/2014 5:25 PM, Nick Coghlan wrote:

On 17 Feb 2014 22:25, "M.-A. Lemburg" <m...@egenix.com
<mailto:m...@egenix.com>> wrote:

 > default_3way_compare(PyObject *v, PyObject *w)
 > ...
 >     /* None is smaller than anything */

Unless it is not, as with datetimes, perhaps other classes written similarly, and some user class instances.

 > Note that it's not important whether None is smaller or greater
 > than any other object. The important aspect is that it's sorting
 > order is consistent and doesn't raise a TypeError when doing an
 > ordered comparison with other objects.

Thanks, that's enough to persuade me that it is a good idea to restore
that behaviour

Would you restore the actual sometimes inconsistent 2.x behavior or implement something new -- what M-A claims but never was? I doubt the former would be trivial since it was part of the now deleted cmp and 3way machinery. To make None a true bottom object, the rich comparison methods would have to special-case None as either argument before looking at the __rc__ special methods of either.

Regardless of how implemented, such a change would break user code that defines a Bottom class and depends on Bottom() < None == True. Given the python-ideas discussions about adding a top or bottom class, I expect that such classes are in use. So a deprecation period would be needed, pushing the change off to 3.7. It is also possible that someone took the ending of cross-type comparisons seriously and is depending on the TypeError.

while True:
  x = f(args)
  try:
    if x > 10: a(x)
    else: b(x)
  except TypeError:
    # f did not return a number
    break

--
Terry Jan Reedy

_______________________________________________
Python-Dev mailing list
Python-Dev@python.org
https://mail.python.org/mailman/listinfo/python-dev
Unsubscribe: 
https://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com

Reply via email to