skillfed

array-api-compat

A wrapper around NumPy and other array libraries to make them compatible with the Array API standard

array-api-compat v1.15.0 2.3M downloads/30d#3,125 on PyPI129
Permissive license MIT Active released

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-compat

uv

uv add array-api-compat

poetry

poetry add array-api-compat

Installing 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

Operating System :: OS IndependentProgramming Language :: Python :: 3Programming Language :: Python :: 3.10Programming Language :: Python :: 3.11Programming Language :: Python :: 3.12Programming Language :: Python :: 3.13Programming Language :: Python :: 3.14Topic :: Software Development :: Libraries :: Python ModulesTyping :: Typed

Tags

array api standard wrappernumpy pytorch compatibility layerarray library abstractionunified array interfacecross-library array apiarray api compliancestandardized array operations
array-api-standardmulti-backendinteroperability

More Python Modules packages