I need to convert a PyObject*
to and int
variable in C.
I understand we can parse arguments with PyArg_ParseTuple
and that we can build Python object using Py_BuildValue
but what is the 'inverse' of Py_BuildValue
?
For instance say I have a Python tuple (1, 2)
and I'd like to use the content of the tuple to access an array :
int x, y;
PyObject* t_0, t_1;
t_0 = PyTuple_GetItem(tuple_ref, 0);
t_1 = PyTuple_GetItem(tuple_ref, 1);
//t_0 and t_1 are of type PyObject* and I need to use them to access a C array
//convert t_0 and t_1 to int and save them in x and y, how?