I have defined a python-c-api class, its real data structure is as follow:
typedef struct _C_CMISS_h
{
PyObject_HEAD // == PyObject ob_base;
TestClass _in_Handle;
}C_CMISS_h;
Here is the destruction function, every time the python class is destructed, this function would be processed.
static void C_CMISS_Destruct(C_CMISS_h* Self){ //reload the destuction method
/*Self->_in_Handle.~TestClass(); //destruct the C class*/
Py_TYPE(Self)->tp_free((PyObject*)Self); //destruct this instance
}
Is it necessary to let this function destruct the C class? Maybe when destructing the python object, Self
could be deleted in the memory, therefore, the _in_Handle
would call the C destruction method automaticly. However, if _in_Handle
would not be deleted, this destruction method would not be processed. Because the destruction method should not be called by twice or more times, I want to know whether it is necessary to call it artificially.