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

Method NumPyBuffer

python/pyarrow/src/arrow/python/numpy_convert.cc:40–53  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

38namespace py {
39
40NumPyBuffer::NumPyBuffer(PyObject* ao) : Buffer(nullptr, 0) {
41 PyAcquireGIL lock;
42 arr_ = ao;
43 Py_INCREF(ao);
44
45 if (PyArray_Check(ao)) {
46 PyArrayObject* ndarray = reinterpret_cast<PyArrayObject*>(ao);
47 auto ptr = reinterpret_cast<uint8_t*>(PyArray_DATA(ndarray));
48 data_ = const_cast<const uint8_t*>(ptr);
49 size_ = PyArray_NBYTES(ndarray);
50 capacity_ = size_;
51 is_mutable_ = !!(PyArray_FLAGS(ndarray) & NPY_ARRAY_WRITEABLE);
52 }
53}
54
55NumPyBuffer::~NumPyBuffer() {
56 // GH-38626: destructor may be called after the Python interpreter is finalized.

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected