| 102 | // Transfer ownership of the native buffer without a per-result Python loop. |
| 103 | template <typename T> |
| 104 | py::array_t<T> owned_array(std::vector<T> values) { |
| 105 | auto buffer = std::make_unique<std::vector<T>>(std::move(values)); |
| 106 | const auto size = static_cast<py::ssize_t>(buffer->size()); |
| 107 | auto *ptr = buffer.get(); |
| 108 | py::capsule owner(ptr, |
| 109 | [](void *p) { delete static_cast<std::vector<T> *>(p); }); |
| 110 | buffer.release(); |
| 111 | return py::array_t<T>({size}, {static_cast<py::ssize_t>(sizeof(T))}, |
| 112 | ptr->data(), owner); |
| 113 | } |
| 114 | |
| 115 | void ZVecPyCollection::Initialize(pybind11::module_ &m) { |
| 116 | py::class_<GroupResult>(m, "_GroupResult") |
no test coverage detected