Hi Jean, You can use "boost::python::ptr(your_cpp_cpointer)" this avoid create unecessary copies.
BR Renato Araujo Oliveira Filho On Tue, Sep 8, 2009 at 11:41 PM, Jean-Sébastien Guay <jean-sebastien.g...@cm-labs.com> wrote: > Hi all, > > I found an post from earlier this year to this list where David Abrahams > said: > > -------------------- > If you want to pass an object by reference to a python function, you > have to wrap it in boost::ref(). Otherwise, it will try to copy the > object and the resulting copy will have to be destroyed after the call. > -------------------- > > http://mail.python.org/pipermail/cplusplus-sig/2009-February/014251.html > > This made me think that perhaps the problem was that the object was being > copied, which will of course only copy according to the static type. > > And yes, wrapping the arguments to call_method in boost::ref() fixes the > problem! Yay! > > And in fact, this fixed the problem for NodeCallback as well. In that case > though, the argument is a pointer: > > void operator()(Node* node, NodeVisitor* nv) > { > try { > call_method<void>(self, "call", boost::ref(node), > boost::ref(nv)); > } > catch (error_already_set) { > NodeCallback::operator()(node, nv); > } > } > > so I don't understand why a copy is being made by call_method, but hey, it > works so I'm happy... > > J-S > -- > ______________________________________________________ > Jean-Sebastien Guay jean-sebastien.g...@cm-labs.com > http://www.cm-labs.com/ > http://whitestar02.webhop.org/ > _______________________________________________ > Cplusplus-sig mailing list > Cplusplus-sig@python.org > http://mail.python.org/mailman/listinfo/cplusplus-sig > _______________________________________________ Cplusplus-sig mailing list Cplusplus-sig@python.org http://mail.python.org/mailman/listinfo/cplusplus-sig