[C++-sig] boost::python constructing object from PyObject *

2008-10-29 Thread Dan Eloff
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 documen

Re: [C++-sig] boost::python constructing object from PyObject *

2008-10-29 Thread Dan Eloff
On Wed, Oct 29, 2008 at 3:29 PM, Alex Mohr <[EMAIL PROTECTED]> wrote: > The documentation isn't great, but the name 'borrowed' is a hint. Using > borrowed instructs boost.python that the PyObject * is a borrowed reference. > So you can use: > > object(handle<>(borrowed(ptr))) > > for when ptr is

Re: [C++-sig] boost::python constructing object from PyObject *

2008-10-29 Thread Dan Eloff
On Wed, Oct 29, 2008 at 3:55 PM, David Abrahams <[EMAIL PROTECTED]> wrote: > The above should be a complete guide. Any questions? Just two. 1) Should it be object(handle<>(borrowed(ptr))) or object(borrowed(ptr)) ? Both seem to compile. 2) Can I repost that to a boost::python wiki, givng you cr