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

Function PyArray_NewFromPool

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

Source from the content-addressed store, hash-verified

275}
276
277Status PyArray_NewFromPool(int nd, npy_intp* dims, PyArray_Descr* descr, MemoryPool* pool,
278 PyObject** out) {
279 // ARROW-6570: Allocate memory from MemoryPool for a couple reasons
280 //
281 // * Track allocations
282 // * Get better performance through custom allocators
283 int64_t total_size = PyDataType_ELSIZE(descr);
284 for (int i = 0; i < nd; ++i) {
285 total_size *= dims[i];
286 }
287
288 ARROW_ASSIGN_OR_RAISE(auto buffer, AllocateBuffer(total_size, pool));
289 *out = PyArray_NewFromDescr(&PyArray_Type, descr, nd, dims,
290 /*strides=*/nullptr,
291 /*data=*/buffer->mutable_data(),
292 /*flags=*/NPY_ARRAY_CARRAY | NPY_ARRAY_WRITEABLE,
293 /*obj=*/nullptr);
294 if (*out == nullptr) {
295 RETURN_IF_PYERROR();
296 // Trust that error set if NULL returned
297 }
298 return SetBufferBase(reinterpret_cast<PyArrayObject*>(*out), std::move(buffer));
299}
300
301template <typename T = void>
302inline 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