[Python-Dev] cmp(x,x)
Gustavo Niemeyer
niemeyer at conectiva.com
Tue May 25 12:50:14 EDT 2004
> > 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.
>
> What does "currently" mean to you? 2.3.3 and HEAD differ here.
I meant HEAD.
> > Going through the function, in a case where v is w and op is
> > either Py_EQ or Py_NE, we have
>
> These cases aren't interesting on HEAD. Nobody calls list_richcompare
> directly. If something calls PyObject_RichCompareBool() with Py_EQ or
> Py_NE, then on HEAD the result is returned instantly, because of this
> code at the start of PyObject_RichCompareBool():
I'm wondering what is causing this confusion then:
% ./python
Python 2.4a0 (#5, May 25 2004, 13:45:26)
[GCC 3.3.3 (release)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
[...]
>>> l = []
>>> l == l
Got in list_richcompare()!
True
>>> if l == l: print "foo"
...
Got in list_richcompare()!
foo
--
Gustavo Niemeyer
http://niemeyer.net
More information about the Python-Dev
mailing list