[C++-sig] set python attribute from C++
Hans Meine
meine at informatik.uni-hamburg.de
Thu Jul 17 10:43:13 CEST 2008
On Donnerstag 17 Juli 2008, Gennadiy Rozental wrote:
> > > So the usage scenario is something like this:
> > >
> > > // this may create objects based on pure C++ classes
> > > // or classes implemented in python.
> > > boost::intrusive_ptr<Base> obj = Factory::create(....);
> >
> > This can't work for "classes implemented in Python." The intrusive_ptr
> > will not be able to maintain Python's reference count.
>
> This is really out of my hands. All our objects are memory managed through
> these intrusive_ptr like smart pointer. I guess what I need is to prevent
> Boost.Python from managing the C++ objects and manually sync lifetime of
> C++ anf python object.
AFAIK, this is what SIP does, since Qt also manages the lifetime itself.
However, that means that you have to check in every operation whether the
underlying C++ object has been deleted (and throw a corresponding Python
exception). Alternatively, you risk crashes and call that usage errors.
(Depending on the actual object lifetimes, this may be practically feasible.)
Ciao, / / .o.
/--/ ..o
/ / ANS ooo
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 197 bytes
Desc: This is a digitally signed message part.
URL: <http://mail.python.org/pipermail/cplusplus-sig/attachments/20080717/2bfefb69/attachment.pgp>
More information about the Cplusplus-sig
mailing list