Boost.Python: Ownership of pointer variables
I'm exposing a C++ tree class using Boost.Python to python. The node class holds a list of child nodes and provides a method void add_child(Node *node) The Node class takes ownership of the provided Node pointer and deletes it's child nodes when the destuctor gets called. I'm exposing the add_child method as: .def("addChild", &Node::add_child) My actual question is: How do i tell Boost.Python that the Node class takes ownership of the child nodes? Because if i execute the following code in python: parentNode = Node() node = Node() parentNode.addChild(node) the object referenced by the node