array-api-compat
A wrapper around NumPy and other array libraries to make them compatible with the Array API standard
What it is and what it does
array-api-compat is a lightweight wrapper that lets you write array code once and run it against multiple array libraries—NumPy, CuPy, PyTorch, Dask, JAX, ndonnx, and sparse—all through a single standardized interface defined by the Array API standard. It abstracts away library-specific quirks and naming differences so your code doesn't need conditional imports or branching logic for different backends.
The package has no runtime dependencies of its own and is designed to be a thin compatibility layer. You import from it instead of directly from your array library, and it delegates to whichever backend you're using. This is useful when building libraries or applications that need to support multiple array backends without duplicating logic, or when you want to let users choose their preferred array library without rewriting your code.
Use it for:
- Build a scientific library that works with NumPy, CuPy, PyTorch, Dask, JAX, ndonnx, and sparse without maintaining separate code paths for each.
- Write code that can run on CPU or GPU by swapping the array backend without changing operations.
- Create a machine learning framework that accepts arrays from any supported library and processes them uniformly.
- Migrate code between array libraries by changing only the import statement, not the operations themselves.
- Develop educational materials or examples that work across multiple array libraries without duplication.
Worth the install?
AI-flagged interpretation of the facts on this page — verify before relying
Provides a unified wrapper around NumPy, CuPy, PyTorch, Dask, JAX, ndonnx, and sparse that implements the Array API standard, allowing code to work consistently across different array libraries.
Yes, if you are building a library or application that needs to support multiple array backends. The package is actively maintained, has no external dependencies, and MIT-licensed. Install it if you want to write array code once and let users choose their backend; skip it if you are locked to a single array library.
Install
array-api-compat on PyPI
pip
pip install array-api-compatuv
uv add array-api-compatpoetry
poetry add array-api-compatInstalling array-api-compat
Before you install
Low friction install with no runtime dependencies. Actively maintained with a recent release and steady commit activity.
License in practice
MIT license permits unrestricted use, modification, and distribution in both open-source and commercial projects with minimal obligations.
Quickstart
pip install array-api-compat
# Then import and use with your chosen array library
import array_api_compat
Requires Python 3.10 or later; the underlying array library (NumPy, CuPy, PyTorch, Dask, JAX, ndonnx, or sparse) must be installed separately.
Verify before relying
- Whether the wrapper introduces measurable performance overhead compared to direct library calls
- Coverage completeness: which Array API operations are fully supported versus partially implemented across all supported libraries
- How to select or switch between supported array backends at runtime
Package facts
| License | MIT (permissive) |
| Python support | supports the current Python release (>=3.10) |
| Install friction | low — pure-Python wheel |
| Runtime dependencies | none |
| Maintenance | actively maintained — 68 days since the last release |
| Last repo commit | |
| First released | |
| Downloads | 2,341,327/month — #3,125 on PyPI (30-day window, as of 2026-08-14) |
| Known vulnerabilities | none known (OSV.dev, checked 2026-08-14) |
Evidence: array_api_compat-1.15.0-py3-none-any.whl
Tags
More Python Modules packages
Converts domain names between Unicode and…
permissive · top 100 on PyPI
setuptoolsSetuptools is a Python build backend and…
permissive · top 100 on PyPI
PyYAMLPyYAML parses and emits YAML 1.1 data format,…
permissive · top 100 on PyPI
pydanticPydantic validates Python data structures…
permissive · top 100 on PyPI
annotated-typesProvides reusable metadata objects for use with…
permissive · top 100 on PyPI
typing-inspectionProvides runtime tools to inspect and…
permissive · top 100 on PyPI
array-api-strictProvides a strict, minimal implementation of…
permissive · top 15,000 on PyPI
fast-array-utilsConverts and computes statistics across sparse,…
copyleft · top 15,000 on PyPI
array-api-extraProvides extra array manipulation functions…
permissive · top 15,000 on PyPI
autorayAutoray provides automatic dispatch of array…
permissive · top 15,000 on PyPI
dataframe-api-compatProvides a lightweight compatibility layer that…
permissive · top 15,000 on PyPI
cupy-cuda12xCuPy provides a NumPy- and SciPy-compatible…
permissive · top 5,000 on PyPI
cupy-cuda13xCuPy provides a NumPy and SciPy-compatible…
permissive · top 15,000 on PyPI
sparseProvides multi-dimensional sparse array data…
permissive · top 5,000 on PyPI
jax-jumpyJax-jumpy provides a unified interface that…
permissive · top 15,000 on PyPI
coolacoola compares complex nested data structures…
permissive · top 5,000 on PyPI