summaryrefslogtreecommitdiff
path: root/Modules/_heapqmodule.c
diff options
context:
space:
mode:
authorRaymond Hettinger <python@rcn.com>2008-06-11 12:39:09 +0000
committerRaymond Hettinger <python@rcn.com>2008-06-11 12:39:09 +0000
commit6fbfb481b82d101902bb20c17d9d42cd32beb160 (patch)
treec93fb97421c9cd1ece2e4d71891df76a20b9f55d /Modules/_heapqmodule.c
parente605e4f09a691aa68ddd6642f52afde221085e25 (diff)
downloadcpython-git-6fbfb481b82d101902bb20c17d9d42cd32beb160.tar.gz
Optimize previous checkin for heapq.
Diffstat (limited to 'Modules/_heapqmodule.c')
-rw-r--r--Modules/_heapqmodule.c8
1 files changed, 7 insertions, 1 deletions
diff --git a/Modules/_heapqmodule.c b/Modules/_heapqmodule.c
index 8edf626eff..4fd0dd51ef 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)