[C++-sig] Getting object for PyObject (reference counting)

Murray Cumming murrayc at murrayc.com
Fri Feb 27 16:44:37 CET 2009

On Fri, 2009-02-27 at 07:35 -0800, Ralf W. Grosse-Kunstleve wrote:
> The trick is to use boost::python::handle:
> http://www.boost.org/doc/libs/1_38_0/libs/python/doc/v2/handle.html
> For example:
> object python_file((handle<>(borrowed(obj_ptr))));

Thanks, but like much of the documentation, I find that page very
unclear. Is there anything that states more obviously what should be
done in the two cases I mentioned.

> I can't find any definitive documentation that tells me how I should get
> a boost::python::object to wrap an existing PyObject*. I guess that
> there's a way to do it that uses an existing reference, and a way that
> takes an extra reference.
Murray Cumming
murrayc at murrayc.com

More information about the Cplusplus-sig mailing list