I was wondering if it is possible to store any Python object as a void* in Python C API which will be returned later to python as-is.
I tried to do something like this:
store_python_object(PyObject *self, PyObject *args)
{
int retval;
PyObject *self_capsule;
void *stored_object;
/* Parse input arguments */
retval = PyArg_ParseTuple(args,
"OO:store_python_object",
&self_capsule,
&stored_object);
if (!retval) {
return NULL;
}
// More code here...
// Return stored_object to python as-is
}
But this seems to have a weird behavior when storing an int for example (Again, I want to store any Python object, not only int).