> [Greg Ewing] > >> What if the list contains a NaN? > > [Armin Rigo] > > Uh, right. The whole issue with NaNs is muddy. Let's focus on Numeric as > > a much saner example of why you need 'a==a' to return something else than > > True. > > Yes. Please <wink>. I belive that either my question was misinterpreted, or I'm missing something. I'm not suggesting to limit 'a==a' to return True/False only. I'm suggesting to introduce a shortcut in the *list* comparison (more specifically, in list_richcompare), since this is what is currently being done, but with a more expensive logic. Going through the function, in a case where v is w and op is either Py_EQ or Py_NE, we have 1) Both objects are lists, go on. 2) Both objects have the same size, go on. 3) Searching for the first index where items are different, using PyObject_RichCompareBool(), won't find anything. Go on. 4) No more items to compare. Check sizes. 5) Sizes match. Check comparison operator. 6) Return either Py_True or Py_False. This whole logic might be replaced by simply: if (v == w && (op == Py_EQ || op == Py_NE)) { res = (op == Py_EQ ? Py_True : Py_False); Py_INCREF(res); return res; } -- Gustavo Niemeyer http://niemeyer.net
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