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

Ralf W. Grosse-Kunstleve rwgk at yahoo.com
Fri Feb 27 16:35:40 CET 2009

The trick is to use boost::python::handle:


For example:

object python_file((handle<>(borrowed(obj_ptr))));

----- Original Message ----
From: Murray Cumming <murrayc at murrayc.com>
To: cplusplus-sig at python.org
Sent: Friday, February 27, 2009 1:33:10 AM
Subject: [C++-sig] Getting object for PyObject (reference counting)

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.

murrayc at murrayc.com

Cplusplus-sig mailing list
Cplusplus-sig at python.org

More information about the Cplusplus-sig mailing list