No.
First, it is impossible. nb_bool and PyObject_IsTrue() can return only three value: 1 for true, 0 for false, and -1 for error. It is not possible to represent NotImplemented without breaking all extensions.
Currently
if not a:
b()
else:
c()
is equivalent to
if a:
c()
else:
b()
If a is NotImplemented, what branch be executed in every case?
Second, it would not help. Because real-world examples are not always so trivial as "return not self.__lt__(other)". It may be a part of more complex expression, e.g.:
return super().__eq__(other) and self.attr == other.attr
So it may help in some examples, but make bugs in other examples even more mystical. |