| |
| |
| |
| <!DOCTYPE html> |
| <html class="writer-html5" lang="en" > |
| <head> |
| <meta charset="utf-8"> |
| |
| <meta name="viewport" content="width=device-width, initial-scale=1.0"> |
| |
| <title>Using pyarrow from C++ and Cython Code — Apache Arrow v2.0.0</title> |
| |
| |
| |
| <link rel="stylesheet" href="../_static/css/theme.css" type="text/css" /> |
| <link rel="stylesheet" href="../_static/pygments.css" type="text/css" /> |
| |
| |
| |
| |
| |
| |
| |
| <!--[if lt IE 9]> |
| <script src="../_static/js/html5shiv.min.js"></script> |
| <![endif]--> |
| |
| |
| <script type="text/javascript" id="documentation_options" data-url_root="../" src="../_static/documentation_options.js"></script> |
| <script src="../_static/jquery.js"></script> |
| <script src="../_static/underscore.js"></script> |
| <script src="../_static/doctools.js"></script> |
| <script src="../_static/language_data.js"></script> |
| |
| <script type="text/javascript" src="../_static/js/theme.js"></script> |
| |
| |
| <link rel="canonical" href="https://arrow.apache.org/docs/python/extending.html" /> |
| <link rel="index" title="Index" href="../genindex.html" /> |
| <link rel="search" title="Search" href="../search.html" /> |
| <link rel="next" title="API Reference" href="api.html" /> |
| <link rel="prev" title="Extending pyarrow" href="extending_types.html" /> |
|
|
|
|
| <!-- Matomo -->
|
| <script>
|
| var _paq = window._paq = window._paq || [];
|
| /* tracker methods like "setCustomDimension" should be called before "trackPageView" */
|
| _paq.push(["setDoNotTrack", true]);
|
| _paq.push(["disableCookies"]);
|
| _paq.push(['trackPageView']);
|
| _paq.push(['enableLinkTracking']);
|
| (function() {
|
| var u="https://analytics.apache.org/";
|
| _paq.push(['setTrackerUrl', u+'matomo.php']);
|
| _paq.push(['setSiteId', '20']);
|
| var d=document, g=d.createElement('script'), s=d.getElementsByTagName('script')[0];
|
| g.async=true; g.src=u+'matomo.js'; s.parentNode.insertBefore(g,s);
|
| })();
|
| </script>
|
| <!-- End Matomo Code -->
|
|
|
| </head> |
| |
| <body class="wy-body-for-nav"> |
| |
| |
| <div class="wy-grid-for-nav"> |
| |
| <nav data-toggle="wy-nav-shift" class="wy-nav-side"> |
| <div class="wy-side-scroll"> |
| <div class="wy-side-nav-search" > |
| |
| |
| |
| <a href="../index.html" class="icon icon-home" alt="Documentation Home"> Apache Arrow |
| |
| |
| |
| </a> |
| |
| |
| |
| |
| <div class="version"> |
| 2.0.0 |
| </div> |
| |
| |
| |
| |
| <div role="search"> |
| <form id="rtd-search-form" class="wy-form" action="../search.html" method="get"> |
| <input type="text" name="q" placeholder="Search docs" /> |
| <input type="hidden" name="check_keywords" value="yes" /> |
| <input type="hidden" name="area" value="default" /> |
| </form> |
| </div> |
| |
| |
| </div> |
| |
| |
| <div class="wy-menu wy-menu-vertical" data-spy="affix" role="navigation" aria-label="main navigation"> |
| |
| |
| |
| |
| |
| |
| <p class="caption"><span class="caption-text">Specifications and Protocols</span></p> |
| <ul> |
| <li class="toctree-l1"><a class="reference internal" href="../format/Versioning.html">Format Versioning and Stability</a></li> |
| <li class="toctree-l1"><a class="reference internal" href="../format/Columnar.html">Arrow Columnar Format</a></li> |
| <li class="toctree-l1"><a class="reference internal" href="../format/Flight.html">Arrow Flight RPC</a></li> |
| <li class="toctree-l1"><a class="reference internal" href="../format/Integration.html">Integration Testing</a></li> |
| <li class="toctree-l1"><a class="reference internal" href="../format/CDataInterface.html">The Arrow C data interface</a></li> |
| <li class="toctree-l1"><a class="reference internal" href="../format/CStreamInterface.html">The Arrow C stream interface</a></li> |
| <li class="toctree-l1"><a class="reference internal" href="../format/Other.html">Other Data Structures</a></li> |
| </ul> |
| <p class="caption"><span class="caption-text">Libraries</span></p> |
| <ul class="current"> |
| <li class="toctree-l1"><a class="reference internal" href="../status.html">Implementation Status</a></li> |
| <li class="toctree-l1"><a class="reference external" href="https://arrow.apache.org/docs/c_glib/">C/GLib</a></li> |
| <li class="toctree-l1"><a class="reference internal" href="../cpp/index.html">C++</a></li> |
| <li class="toctree-l1"><a class="reference external" href="https://github.com/apache/arrow/blob/master/csharp/README.md">C#</a></li> |
| <li class="toctree-l1"><a class="reference external" href="https://godoc.org/github.com/apache/arrow/go/arrow">Go</a></li> |
| <li class="toctree-l1"><a class="reference internal" href="../java/index.html">Java</a></li> |
| <li class="toctree-l1"><a class="reference external" href="https://arrow.apache.org/docs/js/">JavaScript</a></li> |
| <li class="toctree-l1"><a class="reference external" href="https://github.com/apache/arrow/blob/master/matlab/README.md">MATLAB</a></li> |
| <li class="toctree-l1 current"><a class="reference internal" href="index.html">Python</a><ul class="current"> |
| <li class="toctree-l2"><a class="reference internal" href="install.html">Installing PyArrow</a></li> |
| <li class="toctree-l2"><a class="reference internal" href="memory.html">Memory and IO Interfaces</a></li> |
| <li class="toctree-l2"><a class="reference internal" href="data.html">Data Types and In-Memory Data Model</a></li> |
| <li class="toctree-l2"><a class="reference internal" href="compute.html">Compute Functions</a></li> |
| <li class="toctree-l2"><a class="reference internal" href="ipc.html">Streaming, Serialization, and IPC</a></li> |
| <li class="toctree-l2"><a class="reference internal" href="filesystems.html">Filesystem Interface</a></li> |
| <li class="toctree-l2"><a class="reference internal" href="filesystems_deprecated.html">Filesystem Interface (legacy)</a></li> |
| <li class="toctree-l2"><a class="reference internal" href="plasma.html">The Plasma In-Memory Object Store</a></li> |
| <li class="toctree-l2"><a class="reference internal" href="numpy.html">NumPy Integration</a></li> |
| <li class="toctree-l2"><a class="reference internal" href="pandas.html">Pandas Integration</a></li> |
| <li class="toctree-l2"><a class="reference internal" href="timestamps.html">Timestamps</a></li> |
| <li class="toctree-l2"><a class="reference internal" href="csv.html">Reading CSV files</a></li> |
| <li class="toctree-l2"><a class="reference internal" href="feather.html">Feather File Format</a></li> |
| <li class="toctree-l2"><a class="reference internal" href="json.html">Reading JSON files</a></li> |
| <li class="toctree-l2"><a class="reference internal" href="parquet.html">Reading and Writing the Apache Parquet Format</a></li> |
| <li class="toctree-l2"><a class="reference internal" href="dataset.html">Tabular Datasets</a></li> |
| <li class="toctree-l2"><a class="reference internal" href="cuda.html">CUDA Integration</a></li> |
| <li class="toctree-l2"><a class="reference internal" href="extending_types.html">Extending pyarrow</a></li> |
| <li class="toctree-l2 current"><a class="current reference internal" href="#">Using pyarrow from C++ and Cython Code</a><ul> |
| <li class="toctree-l3"><a class="reference internal" href="#c-api">C++ API</a><ul> |
| <li class="toctree-l4"><a class="reference internal" href="#initializing-the-api">Initializing the API</a></li> |
| <li class="toctree-l4"><a class="reference internal" href="#wrapping-and-unwrapping">Wrapping and Unwrapping</a></li> |
| </ul> |
| </li> |
| <li class="toctree-l3"><a class="reference internal" href="#cython-api">Cython API</a><ul> |
| <li class="toctree-l4"><a class="reference internal" href="#id1">Wrapping and Unwrapping</a></li> |
| <li class="toctree-l4"><a class="reference internal" href="#example">Example</a></li> |
| <li class="toctree-l4"><a class="reference internal" href="#building-extensions-against-pypi-wheels">Building Extensions against PyPI Wheels</a></li> |
| </ul> |
| </li> |
| </ul> |
| </li> |
| <li class="toctree-l2"><a class="reference internal" href="api.html">API Reference</a></li> |
| <li class="toctree-l2"><a class="reference internal" href="getting_involved.html">Getting Involved</a></li> |
| <li class="toctree-l2"><a class="reference internal" href="benchmarks.html">Benchmarks</a></li> |
| </ul> |
| </li> |
| <li class="toctree-l1"><a class="reference external" href="https://arrow.apache.org/docs/r/">R</a></li> |
| <li class="toctree-l1"><a class="reference external" href="https://github.com/apache/arrow/blob/master/ruby/README.md">Ruby</a></li> |
| <li class="toctree-l1"><a class="reference external" href="https://docs.rs/crate/arrow/">Rust</a></li> |
| </ul> |
| <p class="caption"><span class="caption-text">Development</span></p> |
| <ul> |
| <li class="toctree-l1"><a class="reference internal" href="../developers/contributing.html">Contributing to Apache Arrow</a></li> |
| <li class="toctree-l1"><a class="reference internal" href="../developers/cpp/index.html">C++ Development</a></li> |
| <li class="toctree-l1"><a class="reference internal" href="../developers/python.html">Python Development</a></li> |
| <li class="toctree-l1"><a class="reference internal" href="../developers/archery.html">Daily Development using Archery</a></li> |
| <li class="toctree-l1"><a class="reference internal" href="../developers/crossbow.html">Packaging and Testing with Crossbow</a></li> |
| <li class="toctree-l1"><a class="reference internal" href="../developers/docker.html">Running Docker Builds</a></li> |
| <li class="toctree-l1"><a class="reference internal" href="../developers/benchmarks.html">Benchmarks</a></li> |
| <li class="toctree-l1"><a class="reference internal" href="../developers/documentation.html">Building the Documentation</a></li> |
| </ul> |
| |
| |
| |
| </div> |
| |
| </div> |
| </nav> |
| |
| <section data-toggle="wy-nav-shift" class="wy-nav-content-wrap"> |
| |
| |
| <nav class="wy-nav-top" aria-label="top navigation"> |
| |
| <i data-toggle="wy-nav-top" class="fa fa-bars"></i> |
| <a href="../index.html">Apache Arrow</a> |
| |
| </nav> |
| |
| |
| <div class="wy-nav-content"> |
| |
| <div class="rst-content"> |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| <div role="navigation" aria-label="breadcrumbs navigation"> |
| |
| <ul class="wy-breadcrumbs"> |
| |
| <li><a href="../index.html" class="icon icon-home"></a> »</li> |
| |
| <li><a href="index.html">Python bindings</a> »</li> |
| |
| <li>Using pyarrow from C++ and Cython Code</li> |
| |
| |
| <li class="wy-breadcrumbs-aside"> |
| |
| |
| <a href="../_sources/python/extending.rst.txt" rel="nofollow"> View page source</a> |
| |
| |
| </li> |
| |
| </ul> |
| |
| |
| <hr/> |
| </div> |
| <div role="main" class="document" itemscope="itemscope" itemtype="http://schema.org/Article"> |
| <div itemprop="articleBody"> |
| |
| <div class="section" id="using-pyarrow-from-c-and-cython-code"> |
| <span id="extending"></span><h1>Using pyarrow from C++ and Cython Code<a class="headerlink" href="#using-pyarrow-from-c-and-cython-code" title="Permalink to this headline">ΒΆ</a></h1> |
| <p>pyarrow features both a Cython and C++ API.</p> |
| <div class="section" id="c-api"> |
| <h2>C++ API<a class="headerlink" href="#c-api" title="Permalink to this headline">ΒΆ</a></h2> |
| <p>The Arrow C++ header files are bundled with a pyarrow installation. |
| To get the absolute path to this directory (like <code class="docutils literal notranslate"><span class="pre">numpy.get_include()</span></code>), use:</p> |
| <div class="highlight-python notranslate"><div class="highlight"><pre><span></span><span class="kn">import</span> <span class="nn">pyarrow</span> <span class="kn">as</span> <span class="nn">pa</span> |
| <span class="n">pa</span><span class="o">.</span><span class="n">get_include</span><span class="p">()</span> |
| </pre></div> |
| </div> |
| <p>Assuming the path above is on your compilerβs include path, the pyarrow API |
| can be included using the following directive:</p> |
| <div class="highlight-cpp notranslate"><div class="highlight"><pre><span></span><span class="cp">#include</span> <span class="cpf"><arrow/python/pyarrow.h></span><span class="cp"></span> |
| </pre></div> |
| </div> |
| <p>This will not include other parts of the Arrow API, which you will need |
| to include yourself (for example <code class="docutils literal notranslate"><span class="pre">arrow/api.h</span></code>).</p> |
| <p>When building C extensions that use the Arrow C++ libraries, you must add |
| appropriate linker flags. We have provided functions <code class="docutils literal notranslate"><span class="pre">pyarrow.get_libraries</span></code> |
| and <code class="docutils literal notranslate"><span class="pre">pyarrow.get_library_dirs</span></code> which return a list of library names and |
| likely library install locations (if you installed pyarrow with pip or |
| conda). These must be included when declaring your C extensions with distutils |
| (see below).</p> |
| <div class="section" id="initializing-the-api"> |
| <h3>Initializing the API<a class="headerlink" href="#initializing-the-api" title="Permalink to this headline">ΒΆ</a></h3> |
| <dl class="cpp function"> |
| <dt id="_CPPv414import_pyarrowv"> |
| <span id="_CPPv314import_pyarrowv"></span><span id="_CPPv214import_pyarrowv"></span><span id="import_pyarrow"></span>int <code class="sig-name descname">import_pyarrow</code><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="headerlink" href="#_CPPv414import_pyarrowv" title="Permalink to this definition">ΒΆ</a><br /></dt> |
| <dd><p>Initialize inner pointers of the pyarrow API. On success, 0 is |
| returned. Otherwise, -1 is returned and a Python exception is set.</p> |
| <p>It is mandatory to call this function before calling any other function |
| in the pyarrow C++ API. Failing to do so will likely lead to crashes.</p> |
| </dd></dl> |
| |
| </div> |
| <div class="section" id="wrapping-and-unwrapping"> |
| <h3>Wrapping and Unwrapping<a class="headerlink" href="#wrapping-and-unwrapping" title="Permalink to this headline">ΒΆ</a></h3> |
| <p>pyarrow provides the following functions to go back and forth between |
| Python wrappers (as exposed by the pyarrow Python API) and the underlying |
| C++ objects.</p> |
| <dl class="cpp function"> |
| <dt id="_CPPv48is_arrayP8PyObject"> |
| <span id="_CPPv38is_arrayP8PyObject"></span><span id="_CPPv28is_arrayP8PyObject"></span><span id="is_array__PyObjectP"></span>bool <code class="sig-name descname">is_array</code><span class="sig-paren">(</span>PyObject *<em>obj</em><span class="sig-paren">)</span><a class="headerlink" href="#_CPPv48is_arrayP8PyObject" title="Permalink to this definition">ΒΆ</a><br /></dt> |
| <dd><p>Return whether <em>obj</em> wraps an Arrow C++ <code class="xref cpp cpp-class docutils literal notranslate"><span class="pre">Array</span></code> pointer; |
| in other words, whether <em>obj</em> is a <a class="reference internal" href="generated/pyarrow.Array.html#pyarrow.Array" title="pyarrow.Array"><code class="xref py py-class docutils literal notranslate"><span class="pre">pyarrow.Array</span></code></a> instance.</p> |
| </dd></dl> |
| |
| <dl class="cpp function"> |
| <dt id="_CPPv49is_bufferP8PyObject"> |
| <span id="_CPPv39is_bufferP8PyObject"></span><span id="_CPPv29is_bufferP8PyObject"></span><span id="is_buffer__PyObjectP"></span>bool <code class="sig-name descname">is_buffer</code><span class="sig-paren">(</span>PyObject *<em>obj</em><span class="sig-paren">)</span><a class="headerlink" href="#_CPPv49is_bufferP8PyObject" title="Permalink to this definition">ΒΆ</a><br /></dt> |
| <dd><p>Return whether <em>obj</em> wraps an Arrow C++ <code class="xref cpp cpp-class docutils literal notranslate"><span class="pre">Buffer</span></code> pointer; |
| in other words, whether <em>obj</em> is a <a class="reference internal" href="generated/pyarrow.Buffer.html#pyarrow.Buffer" title="pyarrow.Buffer"><code class="xref py py-class docutils literal notranslate"><span class="pre">pyarrow.Buffer</span></code></a> instance.</p> |
| </dd></dl> |
| |
| <dl class="cpp function"> |
| <dt id="_CPPv412is_data_typeP8PyObject"> |
| <span id="_CPPv312is_data_typeP8PyObject"></span><span id="_CPPv212is_data_typeP8PyObject"></span><span id="is_data_type__PyObjectP"></span>bool <code class="sig-name descname">is_data_type</code><span class="sig-paren">(</span>PyObject *<em>obj</em><span class="sig-paren">)</span><a class="headerlink" href="#_CPPv412is_data_typeP8PyObject" title="Permalink to this definition">ΒΆ</a><br /></dt> |
| <dd><p>Return whether <em>obj</em> wraps an Arrow C++ <code class="xref cpp cpp-class docutils literal notranslate"><span class="pre">DataType</span></code> pointer; |
| in other words, whether <em>obj</em> is a <a class="reference internal" href="generated/pyarrow.DataType.html#pyarrow.DataType" title="pyarrow.DataType"><code class="xref py py-class docutils literal notranslate"><span class="pre">pyarrow.DataType</span></code></a> instance.</p> |
| </dd></dl> |
| |
| <dl class="cpp function"> |
| <dt id="_CPPv48is_fieldP8PyObject"> |
| <span id="_CPPv38is_fieldP8PyObject"></span><span id="_CPPv28is_fieldP8PyObject"></span><span id="is_field__PyObjectP"></span>bool <code class="sig-name descname">is_field</code><span class="sig-paren">(</span>PyObject *<em>obj</em><span class="sig-paren">)</span><a class="headerlink" href="#_CPPv48is_fieldP8PyObject" title="Permalink to this definition">ΒΆ</a><br /></dt> |
| <dd><p>Return whether <em>obj</em> wraps an Arrow C++ <code class="xref cpp cpp-class docutils literal notranslate"><span class="pre">Field</span></code> pointer; |
| in other words, whether <em>obj</em> is a <a class="reference internal" href="generated/pyarrow.Field.html#pyarrow.Field" title="pyarrow.Field"><code class="xref py py-class docutils literal notranslate"><span class="pre">pyarrow.Field</span></code></a> instance.</p> |
| </dd></dl> |
| |
| <dl class="cpp function"> |
| <dt id="_CPPv415is_record_batchP8PyObject"> |
| <span id="_CPPv315is_record_batchP8PyObject"></span><span id="_CPPv215is_record_batchP8PyObject"></span><span id="is_record_batch__PyObjectP"></span>bool <code class="sig-name descname">is_record_batch</code><span class="sig-paren">(</span>PyObject *<em>obj</em><span class="sig-paren">)</span><a class="headerlink" href="#_CPPv415is_record_batchP8PyObject" title="Permalink to this definition">ΒΆ</a><br /></dt> |
| <dd><p>Return whether <em>obj</em> wraps an Arrow C++ <code class="xref cpp cpp-class docutils literal notranslate"><span class="pre">RecordBatch</span></code> pointer; |
| in other words, whether <em>obj</em> is a <a class="reference internal" href="generated/pyarrow.RecordBatch.html#pyarrow.RecordBatch" title="pyarrow.RecordBatch"><code class="xref py py-class docutils literal notranslate"><span class="pre">pyarrow.RecordBatch</span></code></a> instance.</p> |
| </dd></dl> |
| |
| <dl class="cpp function"> |
| <dt id="_CPPv49is_schemaP8PyObject"> |
| <span id="_CPPv39is_schemaP8PyObject"></span><span id="_CPPv29is_schemaP8PyObject"></span><span id="is_schema__PyObjectP"></span>bool <code class="sig-name descname">is_schema</code><span class="sig-paren">(</span>PyObject *<em>obj</em><span class="sig-paren">)</span><a class="headerlink" href="#_CPPv49is_schemaP8PyObject" title="Permalink to this definition">ΒΆ</a><br /></dt> |
| <dd><p>Return whether <em>obj</em> wraps an Arrow C++ <code class="xref cpp cpp-class docutils literal notranslate"><span class="pre">Schema</span></code> pointer; |
| in other words, whether <em>obj</em> is a <a class="reference internal" href="generated/pyarrow.Schema.html#pyarrow.Schema" title="pyarrow.Schema"><code class="xref py py-class docutils literal notranslate"><span class="pre">pyarrow.Schema</span></code></a> instance.</p> |
| </dd></dl> |
| |
| <dl class="cpp function"> |
| <dt id="_CPPv48is_tableP8PyObject"> |
| <span id="_CPPv38is_tableP8PyObject"></span><span id="_CPPv28is_tableP8PyObject"></span><span id="is_table__PyObjectP"></span>bool <code class="sig-name descname">is_table</code><span class="sig-paren">(</span>PyObject *<em>obj</em><span class="sig-paren">)</span><a class="headerlink" href="#_CPPv48is_tableP8PyObject" title="Permalink to this definition">ΒΆ</a><br /></dt> |
| <dd><p>Return whether <em>obj</em> wraps an Arrow C++ <code class="xref cpp cpp-class docutils literal notranslate"><span class="pre">Table</span></code> pointer; |
| in other words, whether <em>obj</em> is a <a class="reference internal" href="generated/pyarrow.Table.html#pyarrow.Table" title="pyarrow.Table"><code class="xref py py-class docutils literal notranslate"><span class="pre">pyarrow.Table</span></code></a> instance.</p> |
| </dd></dl> |
| |
| <dl class="cpp function"> |
| <dt id="_CPPv49is_tensorP8PyObject"> |
| <span id="_CPPv39is_tensorP8PyObject"></span><span id="_CPPv29is_tensorP8PyObject"></span><span id="is_tensor__PyObjectP"></span>bool <code class="sig-name descname">is_tensor</code><span class="sig-paren">(</span>PyObject *<em>obj</em><span class="sig-paren">)</span><a class="headerlink" href="#_CPPv49is_tensorP8PyObject" title="Permalink to this definition">ΒΆ</a><br /></dt> |
| <dd><p>Return whether <em>obj</em> wraps an Arrow C++ <code class="xref cpp cpp-class docutils literal notranslate"><span class="pre">Tensor</span></code> pointer; |
| in other words, whether <em>obj</em> is a <a class="reference internal" href="generated/pyarrow.Tensor.html#pyarrow.Tensor" title="pyarrow.Tensor"><code class="xref py py-class docutils literal notranslate"><span class="pre">pyarrow.Tensor</span></code></a> instance.</p> |
| </dd></dl> |
| |
| <dl class="cpp function"> |
| <dt id="_CPPv420is_sparse_coo_tensorP8PyObject"> |
| <span id="_CPPv320is_sparse_coo_tensorP8PyObject"></span><span id="_CPPv220is_sparse_coo_tensorP8PyObject"></span><span id="is_sparse_coo_tensor__PyObjectP"></span>bool <code class="sig-name descname">is_sparse_coo_tensor</code><span class="sig-paren">(</span>PyObject *<em>obj</em><span class="sig-paren">)</span><a class="headerlink" href="#_CPPv420is_sparse_coo_tensorP8PyObject" title="Permalink to this definition">ΒΆ</a><br /></dt> |
| <dd><p>Return whether <em>obj</em> wraps an Arrow C++ <code class="xref cpp cpp-class docutils literal notranslate"><span class="pre">SparseCOOTensor</span></code> pointer; |
| in other words, whether <em>obj</em> is a <code class="xref py py-class docutils literal notranslate"><span class="pre">pyarrow.SparseCOOTensor</span></code> instance.</p> |
| </dd></dl> |
| |
| <dl class="cpp function"> |
| <dt id="_CPPv420is_sparse_csr_matrixP8PyObject"> |
| <span id="_CPPv320is_sparse_csr_matrixP8PyObject"></span><span id="_CPPv220is_sparse_csr_matrixP8PyObject"></span><span id="is_sparse_csr_matrix__PyObjectP"></span>bool <code class="sig-name descname">is_sparse_csr_matrix</code><span class="sig-paren">(</span>PyObject *<em>obj</em><span class="sig-paren">)</span><a class="headerlink" href="#_CPPv420is_sparse_csr_matrixP8PyObject" title="Permalink to this definition">ΒΆ</a><br /></dt> |
| <dd><p>Return whether <em>obj</em> wraps an Arrow C++ <code class="xref cpp cpp-class docutils literal notranslate"><span class="pre">SparseCSRMatrix</span></code> pointer; |
| in other words, whether <em>obj</em> is a <code class="xref py py-class docutils literal notranslate"><span class="pre">pyarrow.SparseCSRMatrix</span></code> instance.</p> |
| </dd></dl> |
| |
| <dl class="cpp function"> |
| <dt id="_CPPv420is_sparse_csc_matrixP8PyObject"> |
| <span id="_CPPv320is_sparse_csc_matrixP8PyObject"></span><span id="_CPPv220is_sparse_csc_matrixP8PyObject"></span><span id="is_sparse_csc_matrix__PyObjectP"></span>bool <code class="sig-name descname">is_sparse_csc_matrix</code><span class="sig-paren">(</span>PyObject *<em>obj</em><span class="sig-paren">)</span><a class="headerlink" href="#_CPPv420is_sparse_csc_matrixP8PyObject" title="Permalink to this definition">ΒΆ</a><br /></dt> |
| <dd><p>Return whether <em>obj</em> wraps an Arrow C++ <code class="xref cpp cpp-class docutils literal notranslate"><span class="pre">SparseCSCMatrix</span></code> pointer; |
| in other words, whether <em>obj</em> is a <code class="xref py py-class docutils literal notranslate"><span class="pre">pyarrow.SparseCSCMatrix</span></code> instance.</p> |
| </dd></dl> |
| |
| <p>The following functions expect a pyarrow object, unwrap the underlying |
| Arrow C++ API pointer, and put it in the <em>out</em> parameter. The returned |
| <code class="xref cpp cpp-class docutils literal notranslate"><span class="pre">Status</span></code> object must be inspected first to know whether any error |
| occurred. If successful, <em>out</em> is guaranteed to be non-NULL.</p> |
| <dl class="cpp function"> |
| <dt id="_CPPv412unwrap_arrayP8PyObjectPNSt10shared_ptrI5ArrayEE"> |
| <span id="_CPPv312unwrap_arrayP8PyObjectPNSt10shared_ptrI5ArrayEE"></span><span id="_CPPv212unwrap_arrayP8PyObjectPNSt10shared_ptrI5ArrayEE"></span><span id="unwrap_array__PyObjectP.std::shared_ptr:Array:P"></span>Status <code class="sig-name descname">unwrap_array</code><span class="sig-paren">(</span>PyObject *<em>obj</em>, std::shared_ptr<Array> *<em>out</em><span class="sig-paren">)</span><a class="headerlink" href="#_CPPv412unwrap_arrayP8PyObjectPNSt10shared_ptrI5ArrayEE" title="Permalink to this definition">ΒΆ</a><br /></dt> |
| <dd><p>Unwrap the Arrow C++ <code class="xref cpp cpp-class docutils literal notranslate"><span class="pre">Array</span></code> pointer from <em>obj</em> and put it in <em>out</em>.</p> |
| </dd></dl> |
| |
| <dl class="cpp function"> |
| <dt id="_CPPv413unwrap_bufferP8PyObjectPNSt10shared_ptrI6BufferEE"> |
| <span id="_CPPv313unwrap_bufferP8PyObjectPNSt10shared_ptrI6BufferEE"></span><span id="_CPPv213unwrap_bufferP8PyObjectPNSt10shared_ptrI6BufferEE"></span><span id="unwrap_buffer__PyObjectP.std::shared_ptr:Buffer:P"></span>Status <code class="sig-name descname">unwrap_buffer</code><span class="sig-paren">(</span>PyObject *<em>obj</em>, std::shared_ptr<Buffer> *<em>out</em><span class="sig-paren">)</span><a class="headerlink" href="#_CPPv413unwrap_bufferP8PyObjectPNSt10shared_ptrI6BufferEE" title="Permalink to this definition">ΒΆ</a><br /></dt> |
| <dd><p>Unwrap the Arrow C++ <code class="xref cpp cpp-class docutils literal notranslate"><span class="pre">Buffer</span></code> pointer from <em>obj</em> and put it in <em>out</em>.</p> |
| </dd></dl> |
| |
| <dl class="cpp function"> |
| <dt id="_CPPv416unwrap_data_typeP8PyObjectPNSt10shared_ptrI8DataTypeEE"> |
| <span id="_CPPv316unwrap_data_typeP8PyObjectPNSt10shared_ptrI8DataTypeEE"></span><span id="_CPPv216unwrap_data_typeP8PyObjectPNSt10shared_ptrI8DataTypeEE"></span><span id="unwrap_data_type__PyObjectP.std::shared_ptr:DataType:P"></span>Status <code class="sig-name descname">unwrap_data_type</code><span class="sig-paren">(</span>PyObject *<em>obj</em>, std::shared_ptr<DataType> *<em>out</em><span class="sig-paren">)</span><a class="headerlink" href="#_CPPv416unwrap_data_typeP8PyObjectPNSt10shared_ptrI8DataTypeEE" title="Permalink to this definition">ΒΆ</a><br /></dt> |
| <dd><p>Unwrap the Arrow C++ <code class="xref cpp cpp-class docutils literal notranslate"><span class="pre">DataType</span></code> pointer from <em>obj</em> and put it in <em>out</em>.</p> |
| </dd></dl> |
| |
| <dl class="cpp function"> |
| <dt id="_CPPv412unwrap_fieldP8PyObjectPNSt10shared_ptrI5FieldEE"> |
| <span id="_CPPv312unwrap_fieldP8PyObjectPNSt10shared_ptrI5FieldEE"></span><span id="_CPPv212unwrap_fieldP8PyObjectPNSt10shared_ptrI5FieldEE"></span><span id="unwrap_field__PyObjectP.std::shared_ptr:Field:P"></span>Status <code class="sig-name descname">unwrap_field</code><span class="sig-paren">(</span>PyObject *<em>obj</em>, std::shared_ptr<Field> *<em>out</em><span class="sig-paren">)</span><a class="headerlink" href="#_CPPv412unwrap_fieldP8PyObjectPNSt10shared_ptrI5FieldEE" title="Permalink to this definition">ΒΆ</a><br /></dt> |
| <dd><p>Unwrap the Arrow C++ <code class="xref cpp cpp-class docutils literal notranslate"><span class="pre">Field</span></code> pointer from <em>obj</em> and put it in <em>out</em>.</p> |
| </dd></dl> |
| |
| <dl class="cpp function"> |
| <dt id="_CPPv419unwrap_record_batchP8PyObjectPNSt10shared_ptrI11RecordBatchEE"> |
| <span id="_CPPv319unwrap_record_batchP8PyObjectPNSt10shared_ptrI11RecordBatchEE"></span><span id="_CPPv219unwrap_record_batchP8PyObjectPNSt10shared_ptrI11RecordBatchEE"></span><span id="unwrap_record_batch__PyObjectP.std::shared_ptr:RecordBatch:P"></span>Status <code class="sig-name descname">unwrap_record_batch</code><span class="sig-paren">(</span>PyObject *<em>obj</em>, std::shared_ptr<RecordBatch> *<em>out</em><span class="sig-paren">)</span><a class="headerlink" href="#_CPPv419unwrap_record_batchP8PyObjectPNSt10shared_ptrI11RecordBatchEE" title="Permalink to this definition">ΒΆ</a><br /></dt> |
| <dd><p>Unwrap the Arrow C++ <code class="xref cpp cpp-class docutils literal notranslate"><span class="pre">RecordBatch</span></code> pointer from <em>obj</em> and put it in <em>out</em>.</p> |
| </dd></dl> |
| |
| <dl class="cpp function"> |
| <dt id="_CPPv413unwrap_schemaP8PyObjectPNSt10shared_ptrI6SchemaEE"> |
| <span id="_CPPv313unwrap_schemaP8PyObjectPNSt10shared_ptrI6SchemaEE"></span><span id="_CPPv213unwrap_schemaP8PyObjectPNSt10shared_ptrI6SchemaEE"></span><span id="unwrap_schema__PyObjectP.std::shared_ptr:Schema:P"></span>Status <code class="sig-name descname">unwrap_schema</code><span class="sig-paren">(</span>PyObject *<em>obj</em>, std::shared_ptr<Schema> *<em>out</em><span class="sig-paren">)</span><a class="headerlink" href="#_CPPv413unwrap_schemaP8PyObjectPNSt10shared_ptrI6SchemaEE" title="Permalink to this definition">ΒΆ</a><br /></dt> |
| <dd><p>Unwrap the Arrow C++ <code class="xref cpp cpp-class docutils literal notranslate"><span class="pre">Schema</span></code> pointer from <em>obj</em> and put it in <em>out</em>.</p> |
| </dd></dl> |
| |
| <dl class="cpp function"> |
| <dt id="_CPPv412unwrap_tableP8PyObjectPNSt10shared_ptrI5TableEE"> |
| <span id="_CPPv312unwrap_tableP8PyObjectPNSt10shared_ptrI5TableEE"></span><span id="_CPPv212unwrap_tableP8PyObjectPNSt10shared_ptrI5TableEE"></span><span id="unwrap_table__PyObjectP.std::shared_ptr:Table:P"></span>Status <code class="sig-name descname">unwrap_table</code><span class="sig-paren">(</span>PyObject *<em>obj</em>, std::shared_ptr<Table> *<em>out</em><span class="sig-paren">)</span><a class="headerlink" href="#_CPPv412unwrap_tableP8PyObjectPNSt10shared_ptrI5TableEE" title="Permalink to this definition">ΒΆ</a><br /></dt> |
| <dd><p>Unwrap the Arrow C++ <code class="xref cpp cpp-class docutils literal notranslate"><span class="pre">Table</span></code> pointer from <em>obj</em> and put it in <em>out</em>.</p> |
| </dd></dl> |
| |
| <dl class="cpp function"> |
| <dt id="_CPPv413unwrap_tensorP8PyObjectPNSt10shared_ptrI6TensorEE"> |
| <span id="_CPPv313unwrap_tensorP8PyObjectPNSt10shared_ptrI6TensorEE"></span><span id="_CPPv213unwrap_tensorP8PyObjectPNSt10shared_ptrI6TensorEE"></span><span id="unwrap_tensor__PyObjectP.std::shared_ptr:Tensor:P"></span>Status <code class="sig-name descname">unwrap_tensor</code><span class="sig-paren">(</span>PyObject *<em>obj</em>, std::shared_ptr<Tensor> *<em>out</em><span class="sig-paren">)</span><a class="headerlink" href="#_CPPv413unwrap_tensorP8PyObjectPNSt10shared_ptrI6TensorEE" title="Permalink to this definition">ΒΆ</a><br /></dt> |
| <dd><p>Unwrap the Arrow C++ <code class="xref cpp cpp-class docutils literal notranslate"><span class="pre">Tensor</span></code> pointer from <em>obj</em> and put it in <em>out</em>.</p> |
| </dd></dl> |
| |
| <dl class="cpp function"> |
| <dt id="_CPPv424unwrap_sparse_coo_tensorP8PyObjectPNSt10shared_ptrI15SparseCOOTensorEE"> |
| <span id="_CPPv324unwrap_sparse_coo_tensorP8PyObjectPNSt10shared_ptrI15SparseCOOTensorEE"></span><span id="_CPPv224unwrap_sparse_coo_tensorP8PyObjectPNSt10shared_ptrI15SparseCOOTensorEE"></span><span id="unwrap_sparse_coo_tensor__PyObjectP.std::shared_ptr:SparseCOOTensor:P"></span>Status <code class="sig-name descname">unwrap_sparse_coo_tensor</code><span class="sig-paren">(</span>PyObject *<em>obj</em>, std::shared_ptr<SparseCOOTensor> *<em>out</em><span class="sig-paren">)</span><a class="headerlink" href="#_CPPv424unwrap_sparse_coo_tensorP8PyObjectPNSt10shared_ptrI15SparseCOOTensorEE" title="Permalink to this definition">ΒΆ</a><br /></dt> |
| <dd><p>Unwrap the Arrow C++ <code class="xref cpp cpp-class docutils literal notranslate"><span class="pre">SparseCOOTensor</span></code> pointer from <em>obj</em> and put it in <em>out</em>.</p> |
| </dd></dl> |
| |
| <dl class="cpp function"> |
| <dt id="_CPPv424unwrap_sparse_csr_matrixP8PyObjectPNSt10shared_ptrI15SparseCSRMatrixEE"> |
| <span id="_CPPv324unwrap_sparse_csr_matrixP8PyObjectPNSt10shared_ptrI15SparseCSRMatrixEE"></span><span id="_CPPv224unwrap_sparse_csr_matrixP8PyObjectPNSt10shared_ptrI15SparseCSRMatrixEE"></span><span id="unwrap_sparse_csr_matrix__PyObjectP.std::shared_ptr:SparseCSRMatrix:P"></span>Status <code class="sig-name descname">unwrap_sparse_csr_matrix</code><span class="sig-paren">(</span>PyObject *<em>obj</em>, std::shared_ptr<SparseCSRMatrix> *<em>out</em><span class="sig-paren">)</span><a class="headerlink" href="#_CPPv424unwrap_sparse_csr_matrixP8PyObjectPNSt10shared_ptrI15SparseCSRMatrixEE" title="Permalink to this definition">ΒΆ</a><br /></dt> |
| <dd><p>Unwrap the Arrow C++ <code class="xref cpp cpp-class docutils literal notranslate"><span class="pre">SparseCSRMatrix</span></code> pointer from <em>obj</em> and put it in <em>out</em>.</p> |
| </dd></dl> |
| |
| <dl class="cpp function"> |
| <dt id="_CPPv424unwrap_sparse_csc_matrixP8PyObjectPNSt10shared_ptrI15SparseCSCMatrixEE"> |
| <span id="_CPPv324unwrap_sparse_csc_matrixP8PyObjectPNSt10shared_ptrI15SparseCSCMatrixEE"></span><span id="_CPPv224unwrap_sparse_csc_matrixP8PyObjectPNSt10shared_ptrI15SparseCSCMatrixEE"></span><span id="unwrap_sparse_csc_matrix__PyObjectP.std::shared_ptr:SparseCSCMatrix:P"></span>Status <code class="sig-name descname">unwrap_sparse_csc_matrix</code><span class="sig-paren">(</span>PyObject *<em>obj</em>, std::shared_ptr<SparseCSCMatrix> *<em>out</em><span class="sig-paren">)</span><a class="headerlink" href="#_CPPv424unwrap_sparse_csc_matrixP8PyObjectPNSt10shared_ptrI15SparseCSCMatrixEE" title="Permalink to this definition">ΒΆ</a><br /></dt> |
| <dd><p>Unwrap the Arrow C++ <code class="xref cpp cpp-class docutils literal notranslate"><span class="pre">SparseCSCMatrix</span></code> pointer from <em>obj</em> and put it in <em>out</em>.</p> |
| </dd></dl> |
| |
| <p>The following functions take an Arrow C++ API pointer and wrap it in a |
| pyarray object of the corresponding type. A new reference is returned. |
| On error, NULL is returned and a Python exception is set.</p> |
| <dl class="cpp function"> |
| <dt id="_CPPv410wrap_arrayRKNSt10shared_ptrI5ArrayEE"> |
| <span id="_CPPv310wrap_arrayRKNSt10shared_ptrI5ArrayEE"></span><span id="_CPPv210wrap_arrayRKNSt10shared_ptrI5ArrayEE"></span><span id="wrap_array__std::shared_ptr:Array:CR"></span>PyObject *<code class="sig-name descname">wrap_array</code><span class="sig-paren">(</span><em class="property">const</em> std::shared_ptr<Array> &<em>array</em><span class="sig-paren">)</span><a class="headerlink" href="#_CPPv410wrap_arrayRKNSt10shared_ptrI5ArrayEE" title="Permalink to this definition">ΒΆ</a><br /></dt> |
| <dd><p>Wrap the Arrow C++ <em>array</em> in a <a class="reference internal" href="generated/pyarrow.Array.html#pyarrow.Array" title="pyarrow.Array"><code class="xref py py-class docutils literal notranslate"><span class="pre">pyarrow.Array</span></code></a> instance.</p> |
| </dd></dl> |
| |
| <dl class="cpp function"> |
| <dt id="_CPPv411wrap_bufferRKNSt10shared_ptrI6BufferEE"> |
| <span id="_CPPv311wrap_bufferRKNSt10shared_ptrI6BufferEE"></span><span id="_CPPv211wrap_bufferRKNSt10shared_ptrI6BufferEE"></span><span id="wrap_buffer__std::shared_ptr:Buffer:CR"></span>PyObject *<code class="sig-name descname">wrap_buffer</code><span class="sig-paren">(</span><em class="property">const</em> std::shared_ptr<Buffer> &<em>buffer</em><span class="sig-paren">)</span><a class="headerlink" href="#_CPPv411wrap_bufferRKNSt10shared_ptrI6BufferEE" title="Permalink to this definition">ΒΆ</a><br /></dt> |
| <dd><p>Wrap the Arrow C++ <em>buffer</em> in a <a class="reference internal" href="generated/pyarrow.Buffer.html#pyarrow.Buffer" title="pyarrow.Buffer"><code class="xref py py-class docutils literal notranslate"><span class="pre">pyarrow.Buffer</span></code></a> instance.</p> |
| </dd></dl> |
| |
| <dl class="cpp function"> |
| <dt id="_CPPv414wrap_data_typeRKNSt10shared_ptrI8DataTypeEE"> |
| <span id="_CPPv314wrap_data_typeRKNSt10shared_ptrI8DataTypeEE"></span><span id="_CPPv214wrap_data_typeRKNSt10shared_ptrI8DataTypeEE"></span><span id="wrap_data_type__std::shared_ptr:DataType:CR"></span>PyObject *<code class="sig-name descname">wrap_data_type</code><span class="sig-paren">(</span><em class="property">const</em> std::shared_ptr<DataType> &<em>data_type</em><span class="sig-paren">)</span><a class="headerlink" href="#_CPPv414wrap_data_typeRKNSt10shared_ptrI8DataTypeEE" title="Permalink to this definition">ΒΆ</a><br /></dt> |
| <dd><p>Wrap the Arrow C++ <em>data_type</em> in a <a class="reference internal" href="generated/pyarrow.DataType.html#pyarrow.DataType" title="pyarrow.DataType"><code class="xref py py-class docutils literal notranslate"><span class="pre">pyarrow.DataType</span></code></a> instance.</p> |
| </dd></dl> |
| |
| <dl class="cpp function"> |
| <dt id="_CPPv410wrap_fieldRKNSt10shared_ptrI5FieldEE"> |
| <span id="_CPPv310wrap_fieldRKNSt10shared_ptrI5FieldEE"></span><span id="_CPPv210wrap_fieldRKNSt10shared_ptrI5FieldEE"></span><span id="wrap_field__std::shared_ptr:Field:CR"></span>PyObject *<code class="sig-name descname">wrap_field</code><span class="sig-paren">(</span><em class="property">const</em> std::shared_ptr<Field> &<em>field</em><span class="sig-paren">)</span><a class="headerlink" href="#_CPPv410wrap_fieldRKNSt10shared_ptrI5FieldEE" title="Permalink to this definition">ΒΆ</a><br /></dt> |
| <dd><p>Wrap the Arrow C++ <em>field</em> in a <a class="reference internal" href="generated/pyarrow.Field.html#pyarrow.Field" title="pyarrow.Field"><code class="xref py py-class docutils literal notranslate"><span class="pre">pyarrow.Field</span></code></a> instance.</p> |
| </dd></dl> |
| |
| <dl class="cpp function"> |
| <dt id="_CPPv417wrap_record_batchRKNSt10shared_ptrI11RecordBatchEE"> |
| <span id="_CPPv317wrap_record_batchRKNSt10shared_ptrI11RecordBatchEE"></span><span id="_CPPv217wrap_record_batchRKNSt10shared_ptrI11RecordBatchEE"></span><span id="wrap_record_batch__std::shared_ptr:RecordBatch:CR"></span>PyObject *<code class="sig-name descname">wrap_record_batch</code><span class="sig-paren">(</span><em class="property">const</em> std::shared_ptr<RecordBatch> &<em>batch</em><span class="sig-paren">)</span><a class="headerlink" href="#_CPPv417wrap_record_batchRKNSt10shared_ptrI11RecordBatchEE" title="Permalink to this definition">ΒΆ</a><br /></dt> |
| <dd><p>Wrap the Arrow C++ record <em>batch</em> in a <a class="reference internal" href="generated/pyarrow.RecordBatch.html#pyarrow.RecordBatch" title="pyarrow.RecordBatch"><code class="xref py py-class docutils literal notranslate"><span class="pre">pyarrow.RecordBatch</span></code></a> instance.</p> |
| </dd></dl> |
| |
| <dl class="cpp function"> |
| <dt id="_CPPv411wrap_schemaRKNSt10shared_ptrI6SchemaEE"> |
| <span id="_CPPv311wrap_schemaRKNSt10shared_ptrI6SchemaEE"></span><span id="_CPPv211wrap_schemaRKNSt10shared_ptrI6SchemaEE"></span><span id="wrap_schema__std::shared_ptr:Schema:CR"></span>PyObject *<code class="sig-name descname">wrap_schema</code><span class="sig-paren">(</span><em class="property">const</em> std::shared_ptr<Schema> &<em>schema</em><span class="sig-paren">)</span><a class="headerlink" href="#_CPPv411wrap_schemaRKNSt10shared_ptrI6SchemaEE" title="Permalink to this definition">ΒΆ</a><br /></dt> |
| <dd><p>Wrap the Arrow C++ <em>schema</em> in a <a class="reference internal" href="generated/pyarrow.Schema.html#pyarrow.Schema" title="pyarrow.Schema"><code class="xref py py-class docutils literal notranslate"><span class="pre">pyarrow.Schema</span></code></a> instance.</p> |
| </dd></dl> |
| |
| <dl class="cpp function"> |
| <dt id="_CPPv410wrap_tableRKNSt10shared_ptrI5TableEE"> |
| <span id="_CPPv310wrap_tableRKNSt10shared_ptrI5TableEE"></span><span id="_CPPv210wrap_tableRKNSt10shared_ptrI5TableEE"></span><span id="wrap_table__std::shared_ptr:Table:CR"></span>PyObject *<code class="sig-name descname">wrap_table</code><span class="sig-paren">(</span><em class="property">const</em> std::shared_ptr<Table> &<em>table</em><span class="sig-paren">)</span><a class="headerlink" href="#_CPPv410wrap_tableRKNSt10shared_ptrI5TableEE" title="Permalink to this definition">ΒΆ</a><br /></dt> |
| <dd><p>Wrap the Arrow C++ <em>table</em> in a <a class="reference internal" href="generated/pyarrow.Table.html#pyarrow.Table" title="pyarrow.Table"><code class="xref py py-class docutils literal notranslate"><span class="pre">pyarrow.Table</span></code></a> instance.</p> |
| </dd></dl> |
| |
| <dl class="cpp function"> |
| <dt id="_CPPv411wrap_tensorRKNSt10shared_ptrI6TensorEE"> |
| <span id="_CPPv311wrap_tensorRKNSt10shared_ptrI6TensorEE"></span><span id="_CPPv211wrap_tensorRKNSt10shared_ptrI6TensorEE"></span><span id="wrap_tensor__std::shared_ptr:Tensor:CR"></span>PyObject *<code class="sig-name descname">wrap_tensor</code><span class="sig-paren">(</span><em class="property">const</em> std::shared_ptr<Tensor> &<em>tensor</em><span class="sig-paren">)</span><a class="headerlink" href="#_CPPv411wrap_tensorRKNSt10shared_ptrI6TensorEE" title="Permalink to this definition">ΒΆ</a><br /></dt> |
| <dd><p>Wrap the Arrow C++ <em>tensor</em> in a <a class="reference internal" href="generated/pyarrow.Tensor.html#pyarrow.Tensor" title="pyarrow.Tensor"><code class="xref py py-class docutils literal notranslate"><span class="pre">pyarrow.Tensor</span></code></a> instance.</p> |
| </dd></dl> |
| |
| <dl class="cpp function"> |
| <dt id="_CPPv422wrap_sparse_coo_tensorRKNSt10shared_ptrI15SparseCOOTensorEE"> |
| <span id="_CPPv322wrap_sparse_coo_tensorRKNSt10shared_ptrI15SparseCOOTensorEE"></span><span id="_CPPv222wrap_sparse_coo_tensorRKNSt10shared_ptrI15SparseCOOTensorEE"></span><span id="wrap_sparse_coo_tensor__std::shared_ptr:SparseCOOTensor:CR"></span>PyObject *<code class="sig-name descname">wrap_sparse_coo_tensor</code><span class="sig-paren">(</span><em class="property">const</em> std::shared_ptr<SparseCOOTensor> &<em>sparse_tensor</em><span class="sig-paren">)</span><a class="headerlink" href="#_CPPv422wrap_sparse_coo_tensorRKNSt10shared_ptrI15SparseCOOTensorEE" title="Permalink to this definition">ΒΆ</a><br /></dt> |
| <dd><p>Wrap the Arrow C++ <em>COO sparse tensor</em> in a <code class="xref py py-class docutils literal notranslate"><span class="pre">pyarrow.SparseCOOTensor</span></code> instance.</p> |
| </dd></dl> |
| |
| <dl class="cpp function"> |
| <dt id="_CPPv422wrap_sparse_csr_matrixRKNSt10shared_ptrI15SparseCSRMatrixEE"> |
| <span id="_CPPv322wrap_sparse_csr_matrixRKNSt10shared_ptrI15SparseCSRMatrixEE"></span><span id="_CPPv222wrap_sparse_csr_matrixRKNSt10shared_ptrI15SparseCSRMatrixEE"></span><span id="wrap_sparse_csr_matrix__std::shared_ptr:SparseCSRMatrix:CR"></span>PyObject *<code class="sig-name descname">wrap_sparse_csr_matrix</code><span class="sig-paren">(</span><em class="property">const</em> std::shared_ptr<SparseCSRMatrix> &<em>sparse_tensor</em><span class="sig-paren">)</span><a class="headerlink" href="#_CPPv422wrap_sparse_csr_matrixRKNSt10shared_ptrI15SparseCSRMatrixEE" title="Permalink to this definition">ΒΆ</a><br /></dt> |
| <dd><p>Wrap the Arrow C++ <em>CSR sparse tensor</em> in a <code class="xref py py-class docutils literal notranslate"><span class="pre">pyarrow.SparseCSRMatrix</span></code> instance.</p> |
| </dd></dl> |
| |
| <dl class="cpp function"> |
| <dt id="_CPPv422wrap_sparse_csc_matrixRKNSt10shared_ptrI15SparseCSCMatrixEE"> |
| <span id="_CPPv322wrap_sparse_csc_matrixRKNSt10shared_ptrI15SparseCSCMatrixEE"></span><span id="_CPPv222wrap_sparse_csc_matrixRKNSt10shared_ptrI15SparseCSCMatrixEE"></span><span id="wrap_sparse_csc_matrix__std::shared_ptr:SparseCSCMatrix:CR"></span>PyObject *<code class="sig-name descname">wrap_sparse_csc_matrix</code><span class="sig-paren">(</span><em class="property">const</em> std::shared_ptr<SparseCSCMatrix> &<em>sparse_tensor</em><span class="sig-paren">)</span><a class="headerlink" href="#_CPPv422wrap_sparse_csc_matrixRKNSt10shared_ptrI15SparseCSCMatrixEE" title="Permalink to this definition">ΒΆ</a><br /></dt> |
| <dd><p>Wrap the Arrow C++ <em>CSC sparse tensor</em> in a <code class="xref py py-class docutils literal notranslate"><span class="pre">pyarrow.SparseCSCMatrix</span></code> instance.</p> |
| </dd></dl> |
| |
| </div> |
| </div> |
| <div class="section" id="cython-api"> |
| <h2>Cython API<a class="headerlink" href="#cython-api" title="Permalink to this headline">ΒΆ</a></h2> |
| <p>The Cython API more or less mirrors the C++ API, but the calling convention |
| can be different as required by Cython. In Cython, you donβt need to |
| initialize the API as that will be handled automatically by the <code class="docutils literal notranslate"><span class="pre">cimport</span></code> |
| directive.</p> |
| <div class="admonition note"> |
| <p class="admonition-title">Note</p> |
| <p>Classes from the Arrow C++ API are renamed when exposed in Cython, to |
| avoid named clashes with the corresponding Python classes. For example, |
| C++ Arrow arrays have the <code class="docutils literal notranslate"><span class="pre">CArray</span></code> type and <code class="docutils literal notranslate"><span class="pre">Array</span></code> is the |
| corresponding Python wrapper class.</p> |
| </div> |
| <div class="section" id="id1"> |
| <h3>Wrapping and Unwrapping<a class="headerlink" href="#id1" title="Permalink to this headline">ΒΆ</a></h3> |
| <p>The following functions expect a pyarrow object, unwrap the underlying |
| Arrow C++ API pointer, and return it. NULL is returned (without setting |
| an exception) if the input is not of the right type.</p> |
| <dl class="py function"> |
| <dt id="pyarrow.pyarrow_unwrap_array"> |
| <code class="sig-prename descclassname">pyarrow.</code><code class="sig-name descname">pyarrow_unwrap_array</code><span class="sig-paren">(</span><em class="sig-param"><span class="n">obj</span></em><span class="sig-paren">)</span> → shared_ptr<span class="p">[</span>CArray<span class="p">]</span><a class="headerlink" href="#pyarrow.pyarrow_unwrap_array" title="Permalink to this definition">ΒΆ</a></dt> |
| <dd><p>Unwrap the Arrow C++ <code class="xref cpp cpp-class docutils literal notranslate"><span class="pre">Array</span></code> pointer from <em>obj</em>.</p> |
| </dd></dl> |
| |
| <dl class="py function"> |
| <dt id="pyarrow.pyarrow_unwrap_batch"> |
| <code class="sig-prename descclassname">pyarrow.</code><code class="sig-name descname">pyarrow_unwrap_batch</code><span class="sig-paren">(</span><em class="sig-param"><span class="n">obj</span></em><span class="sig-paren">)</span> → shared_ptr<span class="p">[</span>CRecordBatch<span class="p">]</span><a class="headerlink" href="#pyarrow.pyarrow_unwrap_batch" title="Permalink to this definition">ΒΆ</a></dt> |
| <dd><p>Unwrap the Arrow C++ <code class="xref cpp cpp-class docutils literal notranslate"><span class="pre">RecordBatch</span></code> pointer from <em>obj</em>.</p> |
| </dd></dl> |
| |
| <dl class="py function"> |
| <dt id="pyarrow.pyarrow_unwrap_buffer"> |
| <code class="sig-prename descclassname">pyarrow.</code><code class="sig-name descname">pyarrow_unwrap_buffer</code><span class="sig-paren">(</span><em class="sig-param"><span class="n">obj</span></em><span class="sig-paren">)</span> → shared_ptr<span class="p">[</span>CBuffer<span class="p">]</span><a class="headerlink" href="#pyarrow.pyarrow_unwrap_buffer" title="Permalink to this definition">ΒΆ</a></dt> |
| <dd><p>Unwrap the Arrow C++ <code class="xref cpp cpp-class docutils literal notranslate"><span class="pre">Buffer</span></code> pointer from <em>obj</em>.</p> |
| </dd></dl> |
| |
| <dl class="py function"> |
| <dt id="pyarrow.pyarrow_unwrap_data_type"> |
| <code class="sig-prename descclassname">pyarrow.</code><code class="sig-name descname">pyarrow_unwrap_data_type</code><span class="sig-paren">(</span><em class="sig-param"><span class="n">obj</span></em><span class="sig-paren">)</span> → shared_ptr<span class="p">[</span>CDataType<span class="p">]</span><a class="headerlink" href="#pyarrow.pyarrow_unwrap_data_type" title="Permalink to this definition">ΒΆ</a></dt> |
| <dd><p>Unwrap the Arrow C++ <code class="xref cpp cpp-class docutils literal notranslate"><span class="pre">CDataType</span></code> pointer from <em>obj</em>.</p> |
| </dd></dl> |
| |
| <dl class="py function"> |
| <dt id="pyarrow.pyarrow_unwrap_field"> |
| <code class="sig-prename descclassname">pyarrow.</code><code class="sig-name descname">pyarrow_unwrap_field</code><span class="sig-paren">(</span><em class="sig-param"><span class="n">obj</span></em><span class="sig-paren">)</span> → shared_ptr<span class="p">[</span>CField<span class="p">]</span><a class="headerlink" href="#pyarrow.pyarrow_unwrap_field" title="Permalink to this definition">ΒΆ</a></dt> |
| <dd><p>Unwrap the Arrow C++ <code class="xref cpp cpp-class docutils literal notranslate"><span class="pre">Field</span></code> pointer from <em>obj</em>.</p> |
| </dd></dl> |
| |
| <dl class="py function"> |
| <dt id="pyarrow.pyarrow_unwrap_schema"> |
| <code class="sig-prename descclassname">pyarrow.</code><code class="sig-name descname">pyarrow_unwrap_schema</code><span class="sig-paren">(</span><em class="sig-param"><span class="n">obj</span></em><span class="sig-paren">)</span> → shared_ptr<span class="p">[</span>CSchema<span class="p">]</span><a class="headerlink" href="#pyarrow.pyarrow_unwrap_schema" title="Permalink to this definition">ΒΆ</a></dt> |
| <dd><p>Unwrap the Arrow C++ <code class="xref cpp cpp-class docutils literal notranslate"><span class="pre">Schema</span></code> pointer from <em>obj</em>.</p> |
| </dd></dl> |
| |
| <dl class="py function"> |
| <dt id="pyarrow.pyarrow_unwrap_table"> |
| <code class="sig-prename descclassname">pyarrow.</code><code class="sig-name descname">pyarrow_unwrap_table</code><span class="sig-paren">(</span><em class="sig-param"><span class="n">obj</span></em><span class="sig-paren">)</span> → shared_ptr<span class="p">[</span>CTable<span class="p">]</span><a class="headerlink" href="#pyarrow.pyarrow_unwrap_table" title="Permalink to this definition">ΒΆ</a></dt> |
| <dd><p>Unwrap the Arrow C++ <code class="xref cpp cpp-class docutils literal notranslate"><span class="pre">Table</span></code> pointer from <em>obj</em>.</p> |
| </dd></dl> |
| |
| <dl class="py function"> |
| <dt id="pyarrow.pyarrow_unwrap_tensor"> |
| <code class="sig-prename descclassname">pyarrow.</code><code class="sig-name descname">pyarrow_unwrap_tensor</code><span class="sig-paren">(</span><em class="sig-param"><span class="n">obj</span></em><span class="sig-paren">)</span> → shared_ptr<span class="p">[</span>CTensor<span class="p">]</span><a class="headerlink" href="#pyarrow.pyarrow_unwrap_tensor" title="Permalink to this definition">ΒΆ</a></dt> |
| <dd><p>Unwrap the Arrow C++ <code class="xref cpp cpp-class docutils literal notranslate"><span class="pre">Tensor</span></code> pointer from <em>obj</em>.</p> |
| </dd></dl> |
| |
| <dl class="py function"> |
| <dt id="pyarrow.pyarrow_unwrap_sparse_coo_tensor"> |
| <code class="sig-prename descclassname">pyarrow.</code><code class="sig-name descname">pyarrow_unwrap_sparse_coo_tensor</code><span class="sig-paren">(</span><em class="sig-param"><span class="n">obj</span></em><span class="sig-paren">)</span> → shared_ptr<span class="p">[</span>CSparseCOOTensor<span class="p">]</span><a class="headerlink" href="#pyarrow.pyarrow_unwrap_sparse_coo_tensor" title="Permalink to this definition">ΒΆ</a></dt> |
| <dd><p>Unwrap the Arrow C++ <code class="xref cpp cpp-class docutils literal notranslate"><span class="pre">SparseCOOTensor</span></code> pointer from <em>obj</em>.</p> |
| </dd></dl> |
| |
| <dl class="py function"> |
| <dt id="pyarrow.pyarrow_unwrap_sparse_csr_matrix"> |
| <code class="sig-prename descclassname">pyarrow.</code><code class="sig-name descname">pyarrow_unwrap_sparse_csr_matrix</code><span class="sig-paren">(</span><em class="sig-param"><span class="n">obj</span></em><span class="sig-paren">)</span> → shared_ptr<span class="p">[</span>CSparseCSRMatrix<span class="p">]</span><a class="headerlink" href="#pyarrow.pyarrow_unwrap_sparse_csr_matrix" title="Permalink to this definition">ΒΆ</a></dt> |
| <dd><p>Unwrap the Arrow C++ <code class="xref cpp cpp-class docutils literal notranslate"><span class="pre">SparseCSRMatrix</span></code> pointer from <em>obj</em>.</p> |
| </dd></dl> |
| |
| <dl class="py function"> |
| <dt id="pyarrow.pyarrow_unwrap_sparse_csc_matrix"> |
| <code class="sig-prename descclassname">pyarrow.</code><code class="sig-name descname">pyarrow_unwrap_sparse_csc_matrix</code><span class="sig-paren">(</span><em class="sig-param"><span class="n">obj</span></em><span class="sig-paren">)</span> → shared_ptr<span class="p">[</span>CSparseCSCMatrix<span class="p">]</span><a class="headerlink" href="#pyarrow.pyarrow_unwrap_sparse_csc_matrix" title="Permalink to this definition">ΒΆ</a></dt> |
| <dd><p>Unwrap the Arrow C++ <code class="xref cpp cpp-class docutils literal notranslate"><span class="pre">SparseCSCMatrix</span></code> pointer from <em>obj</em>.</p> |
| </dd></dl> |
| |
| <p>The following functions take a Arrow C++ API pointer and wrap it in a |
| pyarray object of the corresponding type. An exception is raised on error.</p> |
| <dl class="py function"> |
| <dt id="pyarrow.pyarrow_wrap_array"> |
| <code class="sig-prename descclassname">pyarrow.</code><code class="sig-name descname">pyarrow_wrap_array</code><span class="sig-paren">(</span><em class="sig-param">sp_array: const shared_ptr[CArray]& array</em><span class="sig-paren">)</span> → object<a class="headerlink" href="#pyarrow.pyarrow_wrap_array" title="Permalink to this definition">ΒΆ</a></dt> |
| <dd><p>Wrap the Arrow C++ <em>array</em> in a Python <a class="reference internal" href="generated/pyarrow.Array.html#pyarrow.Array" title="pyarrow.Array"><code class="xref py py-class docutils literal notranslate"><span class="pre">pyarrow.Array</span></code></a> instance.</p> |
| </dd></dl> |
| |
| <dl class="py function"> |
| <dt id="pyarrow.pyarrow_wrap_batch"> |
| <code class="sig-prename descclassname">pyarrow.</code><code class="sig-name descname">pyarrow_wrap_batch</code><span class="sig-paren">(</span><em class="sig-param">sp_array: const shared_ptr[CRecordBatch]& batch</em><span class="sig-paren">)</span> → object<a class="headerlink" href="#pyarrow.pyarrow_wrap_batch" title="Permalink to this definition">ΒΆ</a></dt> |
| <dd><p>Wrap the Arrow C++ record <em>batch</em> in a Python <a class="reference internal" href="generated/pyarrow.RecordBatch.html#pyarrow.RecordBatch" title="pyarrow.RecordBatch"><code class="xref py py-class docutils literal notranslate"><span class="pre">pyarrow.RecordBatch</span></code></a> instance.</p> |
| </dd></dl> |
| |
| <dl class="py function"> |
| <dt id="pyarrow.pyarrow_wrap_buffer"> |
| <code class="sig-prename descclassname">pyarrow.</code><code class="sig-name descname">pyarrow_wrap_buffer</code><span class="sig-paren">(</span><em class="sig-param">sp_array: const shared_ptr[CBuffer]& buffer</em><span class="sig-paren">)</span> → object<a class="headerlink" href="#pyarrow.pyarrow_wrap_buffer" title="Permalink to this definition">ΒΆ</a></dt> |
| <dd><p>Wrap the Arrow C++ <em>buffer</em> in a Python <a class="reference internal" href="generated/pyarrow.Buffer.html#pyarrow.Buffer" title="pyarrow.Buffer"><code class="xref py py-class docutils literal notranslate"><span class="pre">pyarrow.Buffer</span></code></a> instance.</p> |
| </dd></dl> |
| |
| <dl class="py function"> |
| <dt id="pyarrow.pyarrow_wrap_data_type"> |
| <code class="sig-prename descclassname">pyarrow.</code><code class="sig-name descname">pyarrow_wrap_data_type</code><span class="sig-paren">(</span><em class="sig-param">sp_array: const shared_ptr[CDataType]& data_type</em><span class="sig-paren">)</span> → object<a class="headerlink" href="#pyarrow.pyarrow_wrap_data_type" title="Permalink to this definition">ΒΆ</a></dt> |
| <dd><p>Wrap the Arrow C++ <em>data_type</em> in a Python <a class="reference internal" href="generated/pyarrow.DataType.html#pyarrow.DataType" title="pyarrow.DataType"><code class="xref py py-class docutils literal notranslate"><span class="pre">pyarrow.DataType</span></code></a> instance.</p> |
| </dd></dl> |
| |
| <dl class="py function"> |
| <dt id="pyarrow.pyarrow_wrap_field"> |
| <code class="sig-prename descclassname">pyarrow.</code><code class="sig-name descname">pyarrow_wrap_field</code><span class="sig-paren">(</span><em class="sig-param">sp_array: const shared_ptr[CField]& field</em><span class="sig-paren">)</span> → object<a class="headerlink" href="#pyarrow.pyarrow_wrap_field" title="Permalink to this definition">ΒΆ</a></dt> |
| <dd><p>Wrap the Arrow C++ <em>field</em> in a Python <a class="reference internal" href="generated/pyarrow.Field.html#pyarrow.Field" title="pyarrow.Field"><code class="xref py py-class docutils literal notranslate"><span class="pre">pyarrow.Field</span></code></a> instance.</p> |
| </dd></dl> |
| |
| <dl class="py function"> |
| <dt id="pyarrow.pyarrow_wrap_resizable_buffer"> |
| <code class="sig-prename descclassname">pyarrow.</code><code class="sig-name descname">pyarrow_wrap_resizable_buffer</code><span class="sig-paren">(</span><em class="sig-param">sp_array: const shared_ptr[CResizableBuffer]& buffer</em><span class="sig-paren">)</span> → object<a class="headerlink" href="#pyarrow.pyarrow_wrap_resizable_buffer" title="Permalink to this definition">ΒΆ</a></dt> |
| <dd><p>Wrap the Arrow C++ resizable <em>buffer</em> in a Python <a class="reference internal" href="generated/pyarrow.ResizableBuffer.html#pyarrow.ResizableBuffer" title="pyarrow.ResizableBuffer"><code class="xref py py-class docutils literal notranslate"><span class="pre">pyarrow.ResizableBuffer</span></code></a> instance.</p> |
| </dd></dl> |
| |
| <dl class="py function"> |
| <dt id="pyarrow.pyarrow_wrap_schema"> |
| <code class="sig-prename descclassname">pyarrow.</code><code class="sig-name descname">pyarrow_wrap_schema</code><span class="sig-paren">(</span><em class="sig-param">sp_array: const shared_ptr[CSchema]& schema</em><span class="sig-paren">)</span> → object<a class="headerlink" href="#pyarrow.pyarrow_wrap_schema" title="Permalink to this definition">ΒΆ</a></dt> |
| <dd><p>Wrap the Arrow C++ <em>schema</em> in a Python <a class="reference internal" href="generated/pyarrow.Schema.html#pyarrow.Schema" title="pyarrow.Schema"><code class="xref py py-class docutils literal notranslate"><span class="pre">pyarrow.Schema</span></code></a> instance.</p> |
| </dd></dl> |
| |
| <dl class="py function"> |
| <dt id="pyarrow.pyarrow_wrap_table"> |
| <code class="sig-prename descclassname">pyarrow.</code><code class="sig-name descname">pyarrow_wrap_table</code><span class="sig-paren">(</span><em class="sig-param">sp_array: const shared_ptr[CTable]& table</em><span class="sig-paren">)</span> → object<a class="headerlink" href="#pyarrow.pyarrow_wrap_table" title="Permalink to this definition">ΒΆ</a></dt> |
| <dd><p>Wrap the Arrow C++ <em>table</em> in a Python <a class="reference internal" href="generated/pyarrow.Table.html#pyarrow.Table" title="pyarrow.Table"><code class="xref py py-class docutils literal notranslate"><span class="pre">pyarrow.Table</span></code></a> instance.</p> |
| </dd></dl> |
| |
| <dl class="py function"> |
| <dt id="pyarrow.pyarrow_wrap_tensor"> |
| <code class="sig-prename descclassname">pyarrow.</code><code class="sig-name descname">pyarrow_wrap_tensor</code><span class="sig-paren">(</span><em class="sig-param">sp_array: const shared_ptr[CTensor]& tensor</em><span class="sig-paren">)</span> → object<a class="headerlink" href="#pyarrow.pyarrow_wrap_tensor" title="Permalink to this definition">ΒΆ</a></dt> |
| <dd><p>Wrap the Arrow C++ <em>tensor</em> in a Python <a class="reference internal" href="generated/pyarrow.Tensor.html#pyarrow.Tensor" title="pyarrow.Tensor"><code class="xref py py-class docutils literal notranslate"><span class="pre">pyarrow.Tensor</span></code></a> instance.</p> |
| </dd></dl> |
| |
| <dl class="py function"> |
| <dt id="pyarrow.pyarrow_wrap_sparse_coo_tensor"> |
| <code class="sig-prename descclassname">pyarrow.</code><code class="sig-name descname">pyarrow_wrap_sparse_coo_tensor</code><span class="sig-paren">(</span><em class="sig-param">sp_array: const shared_ptr[CSparseCOOTensor]& sparse_tensor</em><span class="sig-paren">)</span> → object<a class="headerlink" href="#pyarrow.pyarrow_wrap_sparse_coo_tensor" title="Permalink to this definition">ΒΆ</a></dt> |
| <dd><p>Wrap the Arrow C++ <em>COO sparse tensor</em> in a Python <code class="xref py py-class docutils literal notranslate"><span class="pre">pyarrow.SparseCOOTensor</span></code> instance.</p> |
| </dd></dl> |
| |
| <dl class="py function"> |
| <dt id="pyarrow.pyarrow_wrap_sparse_csr_matrix"> |
| <code class="sig-prename descclassname">pyarrow.</code><code class="sig-name descname">pyarrow_wrap_sparse_csr_matrix</code><span class="sig-paren">(</span><em class="sig-param">sp_array: const shared_ptr[CSparseCSRMatrix]& sparse_tensor</em><span class="sig-paren">)</span> → object<a class="headerlink" href="#pyarrow.pyarrow_wrap_sparse_csr_matrix" title="Permalink to this definition">ΒΆ</a></dt> |
| <dd><p>Wrap the Arrow C++ <em>CSR sparse tensor</em> in a Python <code class="xref py py-class docutils literal notranslate"><span class="pre">pyarrow.SparseCSRMatrix</span></code> instance.</p> |
| </dd></dl> |
| |
| <dl class="py function"> |
| <dt id="pyarrow.pyarrow_wrap_sparse_csc_matrix"> |
| <code class="sig-prename descclassname">pyarrow.</code><code class="sig-name descname">pyarrow_wrap_sparse_csc_matrix</code><span class="sig-paren">(</span><em class="sig-param">sp_array: const shared_ptr[CSparseCSCMatrix]& sparse_tensor</em><span class="sig-paren">)</span> → object<a class="headerlink" href="#pyarrow.pyarrow_wrap_sparse_csc_matrix" title="Permalink to this definition">ΒΆ</a></dt> |
| <dd><p>Wrap the Arrow C++ <em>CSC sparse tensor</em> in a Python <code class="xref py py-class docutils literal notranslate"><span class="pre">pyarrow.SparseCSCMatrix</span></code> instance.</p> |
| </dd></dl> |
| |
| </div> |
| <div class="section" id="example"> |
| <h3>Example<a class="headerlink" href="#example" title="Permalink to this headline">ΒΆ</a></h3> |
| <p>The following Cython module shows how to unwrap a Python object and call |
| the underlying C++ objectβs API.</p> |
| <div class="highlight-python notranslate"><div class="highlight"><pre><span></span><span class="c1"># distutils: language=c++</span> |
| |
| <span class="kn">from</span> <span class="nn">pyarrow.lib</span> <span class="nn">cimport</span> <span class="o">*</span> |
| |
| |
| <span class="k">def</span> <span class="nf">get_array_length</span><span class="p">(</span><span class="n">obj</span><span class="p">):</span> |
| <span class="c1"># Just an example function accessing both the pyarrow Cython API</span> |
| <span class="c1"># and the Arrow C++ API</span> |
| <span class="n">cdef</span> <span class="n">shared_ptr</span><span class="p">[</span><span class="n">CArray</span><span class="p">]</span> <span class="n">arr</span> <span class="o">=</span> <span class="n">pyarrow_unwrap_array</span><span class="p">(</span><span class="n">obj</span><span class="p">)</span> |
| <span class="k">if</span> <span class="n">arr</span><span class="o">.</span><span class="n">get</span><span class="p">()</span> <span class="o">==</span> <span class="n">NULL</span><span class="p">:</span> |
| <span class="k">raise</span> <span class="ne">TypeError</span><span class="p">(</span><span class="s2">"not an array"</span><span class="p">)</span> |
| <span class="k">return</span> <span class="n">arr</span><span class="o">.</span><span class="n">get</span><span class="p">()</span><span class="o">.</span><span class="n">length</span><span class="p">()</span> |
| </pre></div> |
| </div> |
| <p>To build this module, you will need a slightly customized <code class="docutils literal notranslate"><span class="pre">setup.py</span></code> file |
| (this is assuming the file above is named <code class="docutils literal notranslate"><span class="pre">example.pyx</span></code>):</p> |
| <div class="highlight-python notranslate"><div class="highlight"><pre><span></span><span class="kn">from</span> <span class="nn">distutils.core</span> <span class="kn">import</span> <span class="n">setup</span> |
| <span class="kn">from</span> <span class="nn">Cython.Build</span> <span class="kn">import</span> <span class="n">cythonize</span> |
| |
| <span class="kn">import</span> <span class="nn">os</span> |
| <span class="kn">import</span> <span class="nn">numpy</span> <span class="kn">as</span> <span class="nn">np</span> |
| <span class="kn">import</span> <span class="nn">pyarrow</span> <span class="kn">as</span> <span class="nn">pa</span> |
| |
| |
| <span class="n">ext_modules</span> <span class="o">=</span> <span class="n">cythonize</span><span class="p">(</span><span class="s2">"example.pyx"</span><span class="p">)</span> |
| |
| <span class="k">for</span> <span class="n">ext</span> <span class="ow">in</span> <span class="n">ext_modules</span><span class="p">:</span> |
| <span class="c1"># The Numpy C headers are currently required</span> |
| <span class="n">ext</span><span class="o">.</span><span class="n">include_dirs</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="n">np</span><span class="o">.</span><span class="n">get_include</span><span class="p">())</span> |
| <span class="n">ext</span><span class="o">.</span><span class="n">include_dirs</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="n">pa</span><span class="o">.</span><span class="n">get_include</span><span class="p">())</span> |
| <span class="n">ext</span><span class="o">.</span><span class="n">libraries</span><span class="o">.</span><span class="n">extend</span><span class="p">(</span><span class="n">pa</span><span class="o">.</span><span class="n">get_libraries</span><span class="p">())</span> |
| <span class="n">ext</span><span class="o">.</span><span class="n">library_dirs</span><span class="o">.</span><span class="n">extend</span><span class="p">(</span><span class="n">pa</span><span class="o">.</span><span class="n">get_library_dirs</span><span class="p">())</span> |
| |
| <span class="k">if</span> <span class="n">os</span><span class="o">.</span><span class="n">name</span> <span class="o">==</span> <span class="s1">'posix'</span><span class="p">:</span> |
| <span class="n">ext</span><span class="o">.</span><span class="n">extra_compile_args</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="s1">'-std=c++11'</span><span class="p">)</span> |
| |
| <span class="c1"># Try uncommenting the following line on Linux</span> |
| <span class="c1"># if you get weird linker errors or runtime crashes</span> |
| <span class="c1"># ext.define_macros.append(("_GLIBCXX_USE_CXX11_ABI", "0"))</span> |
| |
| |
| <span class="n">setup</span><span class="p">(</span><span class="n">ext_modules</span><span class="o">=</span><span class="n">ext_modules</span><span class="p">)</span> |
| </pre></div> |
| </div> |
| <p>Compile the extension:</p> |
| <div class="highlight-bash notranslate"><div class="highlight"><pre><span></span>python setup.py build_ext --inplace |
| </pre></div> |
| </div> |
| </div> |
| <div class="section" id="building-extensions-against-pypi-wheels"> |
| <h3>Building Extensions against PyPI Wheels<a class="headerlink" href="#building-extensions-against-pypi-wheels" title="Permalink to this headline">ΒΆ</a></h3> |
| <p>The Python wheels have the Arrow C++ libraries bundled in the top level |
| <code class="docutils literal notranslate"><span class="pre">pyarrow/</span></code> install directory. On Linux and macOS, these libraries have an ABI |
| tag like <code class="docutils literal notranslate"><span class="pre">libarrow.so.17</span></code> which means that linking with <code class="docutils literal notranslate"><span class="pre">-larrow</span></code> using the |
| linker path provided by <code class="docutils literal notranslate"><span class="pre">pyarrow.get_library_dirs()</span></code> will not work right out |
| of the box. To fix this, you must run <code class="docutils literal notranslate"><span class="pre">pyarrow.create_library_symlinks()</span></code> |
| once as a user with write access to the directory where pyarrow is |
| installed. This function will attempt to create symlinks like |
| <code class="docutils literal notranslate"><span class="pre">pyarrow/libarrow.so</span></code>. For example:</p> |
| <div class="highlight-bash notranslate"><div class="highlight"><pre><span></span>pip install pyarrow |
| python -c <span class="s2">"import pyarrow; pyarrow.create_library_symlinks()"</span> |
| </pre></div> |
| </div> |
| </div> |
| </div> |
| </div> |
| |
| |
| </div> |
| |
| </div> |
| <footer> |
| |
| <div class="rst-footer-buttons" role="navigation" aria-label="footer navigation"> |
| |
| <a href="api.html" class="btn btn-neutral float-right" title="API Reference" accesskey="n" rel="next">Next <span class="fa fa-arrow-circle-right"></span></a> |
| |
| |
| <a href="extending_types.html" class="btn btn-neutral float-left" title="Extending pyarrow" accesskey="p" rel="prev"><span class="fa fa-arrow-circle-left"></span> Previous</a> |
| |
| </div> |
| |
| |
| <hr/> |
| |
| <div role="contentinfo"> |
| <p> |
| |
| © Copyright 2016-2019 Apache Software Foundation |
| |
| </p> |
| </div> |
| |
| |
| |
| Built with <a href="http://sphinx-doc.org/">Sphinx</a> using a |
| |
| <a href="https://github.com/rtfd/sphinx_rtd_theme">theme</a> |
| |
| provided by <a href="https://readthedocs.org">Read the Docs</a>. |
| |
| </footer> |
| |
| </div> |
| </div> |
| |
| </section> |
| |
| </div> |
| |
| |
| <script type="text/javascript"> |
| jQuery(function () { |
| SphinxRtdTheme.Navigation.enable(true); |
| }); |
| </script> |
| |
| |
| |
| |
| |
| |
| |
| <script type="text/javascript" src="/docs/_static/versionwarning.js"></script></body> |
| </html> |