Borrowed

Denotes a borrowed reference. (Not part of Python api)

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
) {}

Examples

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

Meta