xtensor-stack/xtensor-python

Python bindings for xtensor

What it solves

It bridges the gap between high-performance C++ array manipulation and the Python ecosystem. It allows developers to use NumPy arrays directly within C++ code without copying data, enabling the use of C++'s speed and advanced features while maintaining compatibility with Python's data structures.

How it works

It uses the pybind11 library to create seamless bindings between C++ and Python. It provides two primary C++ containers—pyarray and pytensor—that wrap NumPy arrays in-place. These containers expose the xtensor library's features, such as broadcasting and lazy evaluation, directly to the NumPy data.

Who it’s for

This library is designed for developers and library authors who need to write high-performance C++ extensions for Python, specifically for applications involving multi-dimensional arrays and numerical computing.

Highlights

  • Enables in-place manipulation of NumPy arrays using C++.
  • Supports NumPy-style broadcasting and lazy computing.
  • Provides pyarray for dynamic dimensions and pytensor for faster, compile-time dimension handling.
  • Includes a pyvectorize tool to easily turn C++ scalar functions into vectorized functions callable from Python.
  • Header-only library with seamless integration via the conda package manager.

Related

  • Project
  • Project
  • Project
  • Project