MCPcopy Create free account
hub / github.com/alibaba/zvec / owned_array

Function owned_array

src/binding/python/model/python_collection.cc:104–113  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

102// Transfer ownership of the native buffer without a per-result Python loop.
103template <typename T>
104py::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
115void ZVecPyCollection::Initialize(pybind11::module_ &m) {
116 py::class_<GroupResult>(m, "_GroupResult")

Callers 1

bind_dql_methodsMethod · 0.85

Calls 4

sizeMethod · 0.45
getMethod · 0.45
releaseMethod · 0.45
dataMethod · 0.45

Tested by

no test coverage detected