[ 
https://issues.apache.org/jira/browse/ARROW-2091?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16352633#comment-16352633
 ] 

Uwe L. Korn commented on ARROW-2091:
------------------------------------

Yes, this is possible using the code supplied in {{arrow/python/pyarrow.h}}:
{code:java}
#include <arrow/python/pyarrow.h>

PyObject* process_table(PyObject* table)
{
    arrow::py::import_pyarrow();
    std::shared_ptr<arrow::Table> tablePtr;
    if (not arrow::py::unwrap_table(table, &tablePtr).ok()) {
      // Handle error
    }
    // work on the tablePtr
}{code}

> Interacting with arrow/pyarrow in C++
> -------------------------------------
>
>                 Key: ARROW-2091
>                 URL: https://issues.apache.org/jira/browse/ARROW-2091
>             Project: Apache Arrow
>          Issue Type: Improvement
>            Reporter: Jun
>            Priority: Minor
>
> I've been searching online for a while but cannot figure out how to do this. 
> Please help if this is already a resolved issue.
> I have a c++/python application that interacts with arrow/pyarrow. I want to 
> write a C++ api that takes python objects directly and operate on them in c++.
> {code:java}
> PyObject* process_table(PyObject* table)
> {
>     // process the arrow table
>     std::shared_ptr<arrow::Table> tablePtr = table; // How?
> }{code}
> The problem here is: how do I extract the internal std::shared_ptr<Table> 
> from the PyObject?
> Unfortunately we are not using cython in our stack, we operate on PyObject * 
> directly in c++.
> I can easily do this on numpy arrays:
> {code:java}
> PyObject * process_array(PyObject* arr)
> {
>     PyArray_Check(arr);
>     // process the PyArrayObject directly
>     ...
> }{code}
> I wonder is there any way to achieve this level of c++ integration without 
> using cython? Thanks!



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)

Reply via email to