mirror of
https://github.com/python/cpython.git
synced 2025-07-23 11:15:24 +00:00
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.
This commit is contained in:
parent
2d84f2c95a
commit
16a77adfbd
6 changed files with 126 additions and 80 deletions
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue