Kaydet (Commit) 6fbfb481 authored tarafından Raymond Hettinger's avatar Raymond Hettinger

Optimize previous checkin for heapq.

üst e605e4f0
...@@ -17,8 +17,14 @@ static int ...@@ -17,8 +17,14 @@ static int
cmp_lt(PyObject *x, PyObject *y) cmp_lt(PyObject *x, PyObject *y)
{ {
int cmp; int cmp;
static PyObject *lt = NULL;
if (PyObject_HasAttrString(x, "__lt__")) if (lt == NULL) {
lt = PyString_FromString("__lt__");
if (lt == NULL)
return -1;
}
if (PyObject_HasAttr(x, lt))
return PyObject_RichCompareBool(x, y, Py_LT); return PyObject_RichCompareBool(x, y, Py_LT);
cmp = PyObject_RichCompareBool(y, x, Py_LE); cmp = PyObject_RichCompareBool(y, x, Py_LE);
if (cmp != -1) if (cmp != -1)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment