[Python-Dev] python 3 niggle: None < 1 raises TypeError
p.f.moore at gmail.com
Mon Feb 17 13:02:13 CET 2014
On 17 February 2014 11:49, Gustavo Carneiro <gjcarneiro at gmail.com> wrote:
>> FWIW, I don't think we need to invent a new name for it, just add
>> an appropriate tp_richcompare slot to the PyNoneType or readd the
>> special case to Object/object.c. This would also aid in porting
>> existing Python 2 code to Python 3.
> Based on your comment, SortsFirst and SortsLast sound like good names ;-)
> These would be "universal sortable objects", that could be compared to any
> other type.
I think that having both is over-engineered. For the use cases I know
of, all that is wanted is *one* object that doesn't raise a TypeError
when compared with any other object, and compares predictably (always
before or always after, doesn't matter which).
Whether that object is None, or whether it should be a new singleton,
is not obvious. The advantage of None is that it's Python 2 compatible
(which aids porting as noted). The advantage of a new object is that
not all uses of None need universal sortability, and indeed in some
cases universal sortability will hide bugs.
More information about the Python-Dev