summaryrefslogtreecommitdiffstats
path: root/Objects/enumobject.c
diff options
context:
space:
mode:
authorRaymond Hettinger <python@rcn.com>2003-11-07 15:38:09 (GMT)
committerRaymond Hettinger <python@rcn.com>2003-11-07 15:38:09 (GMT)
commit1021c44b413ebe264a6187322447ac296a0a18a7 (patch)
tree0dec84fec0f7236cc6dc05cf13e7b3df6eaa23af /Objects/enumobject.c
parentff1f1949820126cce5c17f15c37843ccfd100564 (diff)
downloadcpython-1021c44b413ebe264a6187322447ac296a0a18a7.zip
cpython-1021c44b413ebe264a6187322447ac296a0a18a7.tar.gz
cpython-1021c44b413ebe264a6187322447ac296a0a18a7.tar.bz2
Optimize reversed(list) using a custom iterator.
Diffstat (limited to 'Objects/enumobject.c')
-rw-r--r--Objects/enumobject.c4
1 files changed, 2 insertions, 2 deletions
diff --git a/Objects/enumobject.c b/Objects/enumobject.c
index 998e381..8b2e6e1 100644
--- a/Objects/enumobject.c
+++ b/Objects/enumobject.c
@@ -174,8 +174,8 @@ reversed_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
if (!PyArg_UnpackTuple(args, "reversed", 1, 1, &seq))
return NULL;
- /* Special case optimization for xrange */
- if (PyRange_Check(seq))
+ /* Special case optimization for xrange and lists */
+ if (PyRange_Check(seq) || PyList_Check(seq))
return PyObject_CallMethod(seq, "__reversed__", NULL);
if (!PySequence_Check(seq)) {