summaryrefslogtreecommitdiffstats
path: root/Objects/typeobject.c
diff options
context:
space:
mode:
authorTim Peters <tim.peters@gmail.com>2001-09-08 04:00:12 (GMT)
committerTim Peters <tim.peters@gmail.com>2001-09-08 04:00:12 (GMT)
commit16a77adfbd745c202878fabb0b921514fec7ca16 (patch)
tree988fb5ffb34db1c7a12aa89c100efe1af17e80c6 /Objects/typeobject.c
parent2d84f2c95a59b815ef6864805bb6b04b79d0e106 (diff)
downloadcpython-16a77adfbd745c202878fabb0b921514fec7ca16.zip
cpython-16a77adfbd745c202878fabb0b921514fec7ca16.tar.gz
cpython-16a77adfbd745c202878fabb0b921514fec7ca16.tar.bz2
Generalize operator.indexOf (PySequence_Index) to work with any
iterable object. I'm not sure how that got overlooked before! Got rid of the internal _PySequence_IterContains, introduced a new internal _PySequence_IterSearch, and rewrote all the iteration-based "count of", "index of", and "is the object in it or not?" routines to just call the new function. I suppose it's slower this way, but the code duplication was getting depressing.
Diffstat (limited to 'Objects/typeobject.c')
-rw-r--r--Objects/typeobject.c3
1 files changed, 2 insertions, 1 deletions
diff --git a/Objects/typeobject.c b/Objects/typeobject.c
index f15b096..430e68c 100644
--- a/Objects/typeobject.c
+++ b/Objects/typeobject.c
@@ -2559,7 +2559,8 @@ slot_sq_contains(PyObject *self, PyObject *value)
}
else {
PyErr_Clear();
- return _PySequence_IterContains(self, value);
+ return _PySequence_IterSearch(self, value,
+ PY_ITERSEARCH_CONTAINS);
}
}