[C++-sig] call Python function from C++ without copying the arguments

David Abrahams dave at boostpro.com
Sat Jan 17 13:38:19 CET 2009

on Sat Jan 17 2009, "Sebastian Walter" <walter-AT-mathematik.hu-berlin.de> wrote:

> Hello,
> I want to call a Python function from C++ with an object of a C++ class
> as argument.
> The Python-function should change the argument, so changes are visible
> on the C++ side.
> Boost::Python automatically makes a copy of all the arguments that are
> passed to a callable Python object.
> Is there a way NOT to copy all arguments??

> void my_test_function(object fun_obj){
>         A a;
>         cout<<"a.x="<<a.x<<endl;
>         fun_obj(a);

                  ^^^^^^^^^^^ ^

>         cout<<"a.x="<<a.x<<endl;
> }


Dave Abrahams
BoostPro Computing

More information about the Cplusplus-sig mailing list