Consider the following python ctypes - c++ binding:
// C++
class A
{
public:
void someFunc();
};
A* A_new() { return new A(); }
void A_someFunc(A* obj) { obj->someFunc(); }
void A_destruct(A* obj) { delete obj; }
# python
from ctypes import cdll
libA = cdll.LoadLibrary(some_path)
class A:
def __init__(self):
self.obj = libA.A_new()
def some_func(self):
libA.A_someFunc(self.obj)
What's the best way to delete the c++ object, when the python object is not needed any more.
[edit] I added the delete function that was suggested, however the problem remains by whom and when the function is called. It should be as convenient as possible.