I'm attempting to investigate how Arrow converts a python list into an
equivalent arrow::Array using the C++ API below.
// main.cc
#include <memory>
#include <Python.h>
#include <string>
#include <iostream>
#include <arrow/memory_pool.h>
#include <arrow/python/python_to_arrow.h>
PyObject* clist(void)
{
PyObject* lst = PyList_New(0);
PyList_Append(lst, PyLong_FromLong(1));
PyList_Append(lst, PyLong_FromLong(2));
PyList_Append(lst, PyLong_FromLong(5));
return lst;
}
int main()
{
Py_Initialize();
PyObject* list = clist();
std::shared_ptr<arrow::ChunkedArray> carr;
arrow::py::PyConversionOptions ops;
ops.from_pandas = false;
ops.pool = arrow::default_memory_pool();
ConvertPySequence(list, ops, &carr);
Py_Finalize();
}
The file compiles fine, however I get a segmentation fault at
arrow/cpp/src/arrow/python/iterators.h line 44 on PyCheck_Array.
The error in my debugger is EXC_BAD_ACCESS, however when I interrogate it
in the debug console it appears to be there in memory:
[image: Screen Shot 2019-06-04 at 15.02.25.png]
Any help would be appreciated.
I'm compiling using clang 4.0.1 on OSX // Python 3.7.3 // Arrow
0.14.0-SNAPSHOT which I've built locally using conda.