diff options
Diffstat (limited to 'Include/abstract.h')
-rw-r--r-- | Include/abstract.h | 26 |
1 files changed, 18 insertions, 8 deletions
diff --git a/Include/abstract.h b/Include/abstract.h index f4c1b3e..d736efc 100644 --- a/Include/abstract.h +++ b/Include/abstract.h @@ -988,14 +988,24 @@ xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx*/ DL_IMPORT(int) PySequence_Contains(PyObject *seq, PyObject *ob); /* Return -1 if error; 1 if ob in seq; 0 if ob not in seq. - Use __contains__ if possible, else _PySequence_IterContains(). - */ - - DL_IMPORT(int) _PySequence_IterContains(PyObject *seq, PyObject *ob); - /* - Return -1 if error; 1 if ob in seq; 0 if ob not in seq. - Always uses the iteration protocol, and only Py_EQ comparisons. - */ + Use __contains__ if possible, else _PySequence_IterSearch(). + */ + +#define PY_ITERSEARCH_COUNT 1 +#define PY_ITERSEARCH_INDEX 2 +#define PY_ITERSEARCH_CONTAINS 3 + DL_IMPORT(int) _PySequence_IterSearch(PyObject *seq, PyObject *obj, + int operation); + /* + Iterate over seq. Result depends on the operation: + PY_ITERSEARCH_COUNT: return # of times obj appears in seq; -1 if + error. + PY_ITERSEARCH_INDEX: return 0-based index of first occurence of + obj in seq; set ValueError and return -1 if none found; + also return -1 on error. + PY_ITERSEARCH_CONTAINS: return 1 if obj in seq, else 0; -1 on + error. + */ /* For DLL-level backwards compatibility */ #undef PySequence_In |