MCPcopy Create free account
hub / github.com/apache/arrow / PyArray_NewFromPool

Function PyArray_NewFromPool

python/pyarrow/src/arrow/python/arrow_to_pandas.cc:288–310  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

286}
287
288Status PyArray_NewFromPool(int nd, npy_intp* dims, PyArray_Descr* descr, MemoryPool* pool,
289 PyObject** out) {
290 // ARROW-6570: Allocate memory from MemoryPool for a couple reasons
291 //
292 // * Track allocations
293 // * Get better performance through custom allocators
294 int64_t total_size = PyDataType_ELSIZE(descr);
295 for (int i = 0; i < nd; ++i) {
296 total_size *= dims[i];
297 }
298
299 ARROW_ASSIGN_OR_RAISE(auto buffer, AllocateBuffer(total_size, pool));
300 *out = PyArray_NewFromDescr(&PyArray_Type, descr, nd, dims,
301 /*strides=*/nullptr,
302 /*data=*/buffer->mutable_data(),
303 /*flags=*/NPY_ARRAY_CARRAY | NPY_ARRAY_WRITEABLE,
304 /*obj=*/nullptr);
305 if (*out == nullptr) {
306 RETURN_IF_PYERROR();
307 // Trust that error set if NULL returned
308 }
309 return SetBufferBase(reinterpret_cast<PyArrayObject*>(*out), std::move(buffer));
310}
311
312template <typename T = void>
313inline const T* GetPrimitiveValues(const Array& arr) {

Callers 1

AllocateNDArrayMethod · 0.85

Calls 2

SetBufferBaseFunction · 0.85
mutable_dataMethod · 0.45

Tested by

no test coverage detected