[Gustavo Niemeyer] >> Looking again, this is true for any operation, not only >> Py_EQ or Py_NE. [Jim J Jewett] > CVS has previously restricted the shortcut to those two, > but I agree it should be all or nothing. It could for lists specifically, but not for objects in general. The rich comparison PEP explicitly promised that, for example, x <= y is not necessarily the same as "x < y or x == y": from x == y, we're not allowed to infer that x <= y, or x >= y, or not x < y, or not x > y. For that matter, the PEP http://www.python.org/peps/pep-0207.html also promised 3 The == and != operators are not assumed to be each other's complement so it's also not kosher to infer x != y is False from that x == y is True. Any shortcuts based on object identity are optimizations, and dubious ones because they violate promises made in that PEP. There's a strong pragmatic ("go fast") case for starting to infer "x == y" and "not x != y" from "x is y", but that doesn't extend to inferring others from "x is y" (PyObject_RichCompareBool gets invoked with Py_EQ and Py_NE all over the place in the core; it's never invoked with Py_GT, Py_GE, or Py_LE; there are a few invocations with Py_LT, mostly involved with sorting).
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4