[C++-sig] alternative smart pointer (intrusive_ptr) example

David Abrahams dave at boostpro.com
Tue Jul 29 01:23:44 CEST 2008


on Mon Jul 28 2008, Jeff Webb <jeff.webb-AT-nta-inc.net> wrote:

> Jeff Webb wrote:
>> (1) There is an object identity problem (i.e. 'r.ref is v' is
>> False).  This means that there are two python wrappers for a single
>> C++ object.  In some cases this is okay, but it is not ideal.
>
> In order to solve the object identity problem mentioned above, I needed some method of storing the PyObject pointer that is wrapping a given Pointee object and a way of looking it up.  There are two methods that I have tried:
>
> (1) storing the PyObject pointer in the Pointee object itself

http://www.boost.org/doc/libs/1_35_0/libs/python/doc/v2/has_back_reference.html

> (2) using a global dictionary to store the Pointee->PyObject mappings

Isn't this going to incur comparable memory use to shared_ptr?

-- 
Dave Abrahams
BoostPro Computing
http://www.boostpro.com



More information about the Cplusplus-sig mailing list