On Wed, Sep 24, 2008 at 1:26 PM, Vincent Ferries
<vin...@gm...> wrote:
> I've got the following problem :
>
> I wrap a complex object, we will call it MyObject.
You are wrapping a "class", not object.
> If I modify data in MyObject using some of my wrapped methods, MyObject
> content will be changed.
> I'd like to create a copy from my base MyObject and work on a clone, to
> ensure I keep the initial data safe.
>
> I tried using copy and deepcopy from the python copy module but without
> success.
>
> The initial C++ object doesn't have any clone method.
>
> Does someone has an idea how I could do this?
1. If class has copy constructor you can write MyObject( other
MyObject instance ) and this will work
2. If class has operator=, than P++ exposes it under "assign" name, so
you can use it: my_object.assign( other instance )
3. In order to work with copy or deepcopy, the exposed class should
have __copy__ or __deepcopy__ method.
You can register a C++ function, which does the job, under such
name and you'll be okey.
4. Another option is described
here(http://www.boost.org/doc/libs/1_36_0/libs/python/doc/v2/pickle.html).
Py++ doesn't support such functionality
HTH
--
Roman Yakovenko
C++ Python language binding
http://www.language-binding.net/
|