[C++-sig] Wrappend objects identity problem

Roman Yakovenko roman.yakovenko at gmail.com
Thu Mar 30 13:04:15 CEST 2006


> Thanks for reply. Here is a quote from FAQ:
>
> Another approach to this requires you to change your C++ code a bit; if
> that's an option for you it might be a better way to go. work we've been
> meaning to get to anyway. When a shared_ptr<X> is converted from Python,
> the shared_ptr actually manages a reference to the containing Python
> object. When a shared_ptr<X> is converted back to Python, the library
> checks to see if it's one of those "Python object managers" and if so
> just returns the original Python object. *So you could just write
> object(p) to get the Python object back*. To exploit this you'd have to
> be able to change the C++ code you're wrapping so that it deals with
> shared_ptr instead of raw pointers.
>
> This is suitable approach for me, but phrase marked bold (between **)
> isn't clear for me: where to write "object(p)" and what is 'p' in this
> context?

I could be wrong, but p is instance of shared_ptr and object is
boost::python::object.

> --
> Victor (aka nail) Nakoryakov
> nail-mail<at>mail<dot>ru
>
> Krasnoznamensk, Moscow, Russia

--
Roman Yakovenko
C++ Python language binding
http://www.language-binding.net/



More information about the Cplusplus-sig mailing list