[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:

http://www.boost.org/doc/libs/1_38_0/libs/python/doc/v2/handle.html

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
www.murrayc.com
www.openismus.com

_______________________________________________
Cplusplus-sig mailing list
Cplusplus-sig at python.org
http://mail.python.org/mailman/listinfo/cplusplus-sig



More information about the Cplusplus-sig mailing list