summaryrefslogtreecommitdiffstats
path: root/Objects/listobject.c
diff options
context:
space:
mode:
authorRaymond Hettinger <python@rcn.com>2003-12-13 11:26:12 (GMT)
committerRaymond Hettinger <python@rcn.com>2003-12-13 11:26:12 (GMT)
commit8f5cdaa784f555149adf5e94fd2e989f99d6b1db (patch)
treed6a8f66d75cc46f849b5933fb2a57b41e76a7d4f /Objects/listobject.c
parentfeb78c94fa444a75b912ca355c3c80d7453f03f0 (diff)
downloadcpython-8f5cdaa784f555149adf5e94fd2e989f99d6b1db.zip
cpython-8f5cdaa784f555149adf5e94fd2e989f99d6b1db.tar.gz
cpython-8f5cdaa784f555149adf5e94fd2e989f99d6b1db.tar.bz2
* Added a new method flag, METH_COEXIST.
* Used the flag to optimize set.__contains__(), dict.__contains__(), dict.__getitem__(), and list.__getitem__().
Diffstat (limited to 'Objects/listobject.c')
-rw-r--r--Objects/listobject.c5
1 files changed, 5 insertions, 0 deletions
diff --git a/Objects/listobject.c b/Objects/listobject.c
index 7d5c8b4..3915cc9 100644
--- a/Objects/listobject.c
+++ b/Objects/listobject.c
@@ -2371,6 +2371,8 @@ list_nohash(PyObject *self)
static PyObject *list_iter(PyObject *seq);
static PyObject *list_reversed(PyListObject* seq, PyObject* unused);
+PyDoc_STRVAR(getitem_doc,
+"x.__getitem__(y) <==> x[y]");
PyDoc_STRVAR(reversed_doc,
"L.__reversed__() -- return a reverse iterator over the list");
PyDoc_STRVAR(append_doc,
@@ -2396,7 +2398,10 @@ PyDoc_STRVAR(sorted_doc,
"list.sorted(iterable, cmp=None, key=None, reverse=False) --> new sorted list;\n\
cmp(x, y) -> -1, 0, 1");
+static PyObject *list_subscript(PyListObject*, PyObject*);
+
static PyMethodDef list_methods[] = {
+ {"__getitem__", (PyCFunction)list_subscript, METH_O|METH_COEXIST, getitem_doc},
{"__reversed__",(PyCFunction)list_reversed, METH_NOARGS, reversed_doc},
{"append", (PyCFunction)listappend, METH_O, append_doc},
{"insert", (PyCFunction)listinsert, METH_VARARGS, insert_doc},