Awkward Array: pyobject_deleter< T > Class Template Reference

Loading...
Searching...
No Matches
Public Member Functions | List of all members
pyobject_deleter< T > Class Template Reference

Used as a `std::shared_ptr` deleter (second argument) to overload `delete ptr` with `Py_DECREF(ptr)`. More...

`#include <util.h>`

## Public Member Functions
| pyobject_deleter (PyObject *pyobj)
| Creates a pyobject_deleter and calls `Py_INCREF(ptr)`. More...
void | operator() (T const *p)
| Called by `std::shared_ptr` when its reference count reaches zero. More...

## Detailed Description

template<typename T>
class pyobject_deleter< T >

Used as a `std::shared_ptr` deleter (second argument) to overload `delete ptr` with `Py_DECREF(ptr)`.

This allows data to be shared between C++ and Python that will be deleted when both reference counts reach zero.

The effective reference count is a lexicographical tuple of (Python reference count, C++ reference count), where the Python reference count is the most significant digit. A single Python reference count is held for all C++ references to the object.

See also

- kernel::array_deleter, which frees array buffers, rather than objects.
- kernel::no_deleter, which does not free memory at all (for borrowed references).

## Constructor & Destructor Documentation

## ◆ pyobject_deleter()

pyobject_deleter | ( | PyObject * | pyobj | ) |
| inline

Creates a pyobject_deleter and calls `Py_INCREF(ptr)`.

## Member Function Documentation

## ◆ operator()()

void operator() | ( | T const * | p | ) |
| inline

Called by `std::shared_ptr` when its reference count reaches zero.

The documentation for this class was generated from the following file:

- include/awkward/python/util.h