[C++-sig] boost::python constructing object from PyObject *
Dan Eloff
dan.eloff at gmail.com
Wed Oct 29 21:06:49 CET 2008
When creating an object from a PyObject *, how do you distinguish
between a PyObject pointer that is a new reference (must not be
increfed, but must be decrefed) versus a PyObject * that is a borrowed
reference? (should be increfed and decrefed)
A very simple question for which there is no documented answer,
conflicting answers in the archives of this mailing list, and hours of
googling has turned up conflicting information.
The best I could find was object(borrowed(ptr)) for new references and
object(handle<>(ptr)) for borrowed pointers. I'm not sure if that is
accurate, but if so that deserves a nomination for a terrible
interface award.
Please someone put me out of my misery. What's the interface for this?
-Dan
More information about the Cplusplus-sig
mailing list