diff options
Diffstat (limited to 'Modules/_heapqmodule.c')
| -rw-r--r-- | Modules/_heapqmodule.c | 8 |
1 files changed, 7 insertions, 1 deletions
diff --git a/Modules/_heapqmodule.c b/Modules/_heapqmodule.c index 8edf626..4fd0dd5 100644 --- a/Modules/_heapqmodule.c +++ b/Modules/_heapqmodule.c @@ -17,8 +17,14 @@ static int cmp_lt(PyObject *x, PyObject *y) { 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); cmp = PyObject_RichCompareBool(y, x, Py_LE); if (cmp != -1) |
