[Python-Dev] cmp(x,x) (original) (raw)

Gustavo Niemeyer niemeyer at conectiva.com
Tue May 25 11:40:49 EDT 2004


Going through the function, in a case where v is w and op is either PyEQ or PyNE, we have

Looking again, this is true for any operation, not only Py_EQ or Py_NE. So the shortcut might be:

if (v == w) {
    if (op == Py_EQ || op == Py_LE || op == Py_GE)
        res = Py_True;
    else
        res = Py_False;
     Py_INCREF(res);
     return res;
}

-- Gustavo Niemeyer http://niemeyer.net



More information about the Python-Dev mailing list