ting down to that wrapper type in a thin wrapper
    function. For example:
<pre>
class X { X(int); virtual ~X(); ... };
X* f();  // known to return Xs that are managed by Python objects


// wrapping code

struct X_wrap : X
{
    X_wrap(PyObject* self, int v) : self(self), X(v) {}
    PyObject* self;
};

handle&lt;&gt; f_wrap()
{
    X_wrap* xw = dynamic_cast&lt;X_wrap*&gt;(f());
    assert(xw != 0);
    return handle&lt;&gt;(borrowed(xw-&gt;self));
}

...

def("f", f_wrap());
class_&lt;X,X_wrap&gt;("X", i