Borrowed

Denotes a borrowed reference.

Intended use: An api function Foo returning a borrowed reference will have return type Borrowed!PyObject* instead of PyObject*. Py_INCREF can be used to get the original type back.

extern (C)
struct Borrowed (
T
)

Parameters

T

Python object type (PyObject, PyTypeObject, etc)

Examples

Borrowed!PyObject* borrowed = PyTuple_GetItem(tuple, 0);
PyObject* item = Py_XINCREF(borrowed);

Meta