Writing a Python extension module which is intended to speed up execution of a function written as Python script I am stuck with the problem of how to check in C-code of a Python extension module if a C-Python object is in a C-Python set/list of C-Python objects.
In other words what I am looking after is the equivalent of Python script expression item in list/set
in C code of a Python extension module.
Any hints how to accomplish this are welcome.
int
PySequence_Contains(PyObject *o, PyObject *value)
Determine if o contains value. If an item in o is equal to value, return
1
, otherwise return0
. On error, return-1
. This is equivalent to the Python expressionvalue in o
.