Observed since 20 Oct, 17:51 UTC
No superseded metadata states collected. Unchanged observations do not create new revisions.
Backend-independent array control-flow primitives
Array Control-flow And Iteration: small, backend-independent control-flow primitives for code written with the Python Array API ecosystem.
Install acai with:
pip install acai-control
Array backends such as NumPy, CuPy, JAX, and PyTorch are not installed by
acai-control. array-api-compat provides namespace inference and backend
detection, while Optree provides pytree
traversal.
The acai namespace provides four main functions:
cond: Apply one of two functions according to a scalar predicate.fori_loop: Apply a function over an integer range.scan: Scan a function over arrays while carrying state.while_loop: Apply a function repeatedly while a condition is true.The basic usage is:
import numpy as np
from array_api_compat import array_namespace
from acai import cond, fori_loop, scan, while_loop
x = np.asarray(1)
xp = array_namespace(x)
# 1 * 2 * 3 * 4 * 5
factorial = fori_loop(1, 6, lambda i, value: value * i, x, xp=xp)
# The namespace may also be inferred from an array carry.
power_of_two = while_loop(lambda value: value < 16, lambda value: value * 2, x)
# Select one branch without losing staged control flow on JAX.
magnitude = cond(x >= 0, lambda value: value, lambda value: -value, x, xp=xp)
# Accumulate values and collect every intermediate total.
total, cumulative = scan(
lambda carry, value: (carry + value, carry + value),
np.asarray(0),
np.asarray([1, 2, 3]),
)
The loop functions use ordinary Python loops for NumPy, CuPy, and PyTorch. For
JAX, they dispatch to jax.lax.while_loop and jax.lax.fori_loop, so
loops remain staged under jax.jit. Likewise, cond uses ordinary Python
branching except on JAX, where it dispatches to jax.lax.cond. scan uses
eager iteration and stacking except on JAX, where it dispatches directly to
jax.lax.scan.
PyTorch arrays are supported through eager Python control flow. PyTorch's
native structured control-flow primitives are currently prototype features, so
acai does not dispatch to them. Consequently, its control flow is not
guaranteed to remain structured under torch.compile.
Dask arrays and ndonnx symbolic arrays are not currently supported. All
primitives raise NotImplementedError when given either namespace.
acai is not part of the Python Array API standard and is not
affiliated with array-api-compat or array-api-extra.
pypistats · 57 observations shown. Missing days are unknown. Source category: overall: without mirrors.
| Date / source period | Value | Observed at |
|---|---|---|
| 2026-10-18 – 2026-10-18 | 1 | 2026-10-20T22:08:03.4359476Z |
| 2026-10-17 – 2026-10-17 | 3 | 2026-10-20T22:08:03.4359476Z |
| 2026-10-15 – 2026-10-15 | 5 | 2026-10-20T22:08:03.4359476Z |
| 2026-10-14 – 2026-10-14 | 4 | 2026-10-20T22:08:03.4359476Z |
| 2026-10-13 – 2026-10-13 | 9 | 2026-10-20T22:08:03.4359476Z |
| 2026-10-12 – 2026-10-12 | 4 | 2026-10-20T22:08:03.4359476Z |
| 2026-10-10 – 2026-10-10 | 4 | 2026-10-20T22:08:03.4359476Z |
| 2026-10-09 – 2026-10-09 | 9 | 2026-10-20T22:08:03.4359476Z |
| 2026-10-08 – 2026-10-08 | 3 | 2026-10-20T22:08:03.4359476Z |
| 2026-10-07 – 2026-10-07 | 1 | 2026-10-20T22:08:03.4359476Z |
| 2026-10-06 – 2026-10-06 | 1 | 2026-10-20T22:08:03.4359476Z |
| 2026-10-05 – 2026-10-05 | 2 | 2026-10-20T22:08:03.4359476Z |
| 2026-10-02 – 2026-10-02 | 5 | 2026-10-20T22:08:03.4359476Z |
| 2026-10-01 – 2026-10-01 | 2 | 2026-10-20T22:08:03.4359476Z |
| 2026-09-30 – 2026-09-30 | 4 | 2026-10-20T22:08:03.4359476Z |
| 2026-09-29 – 2026-09-29 | 1 | 2026-10-20T22:08:03.4359476Z |
| 2026-09-28 – 2026-09-28 | 2 | 2026-10-20T22:08:03.4359476Z |
| 2026-09-27 – 2026-09-27 | 2 | 2026-10-20T22:08:03.4359476Z |
| 2026-09-26 – 2026-09-26 | 4 | 2026-10-20T22:08:03.4359476Z |
| 2026-09-25 – 2026-09-25 | 5 | 2026-10-20T22:08:03.4359476Z |
| 2026-09-23 – 2026-09-23 | 1 | 2026-10-20T22:08:03.4359476Z |
| 2026-09-22 – 2026-09-22 | 2 | 2026-10-20T22:08:03.4359476Z |
| 2026-09-21 – 2026-09-21 | 3 | 2026-10-20T22:08:03.4359476Z |
| 2026-09-20 – 2026-09-20 | 2 | 2026-10-20T22:08:03.4359476Z |
| 2026-09-18 – 2026-09-18 | 30 | 2026-10-20T22:08:03.4359476Z |
| 2026-09-17 – 2026-09-17 | 3 | 2026-10-20T22:08:03.4359476Z |
| 2026-09-16 – 2026-09-16 | 9 | 2026-10-20T22:08:03.4359476Z |
| 2026-09-15 – 2026-09-15 | 14 | 2026-10-20T22:08:03.4359476Z |
| 2026-09-14 – 2026-09-14 | 38 | 2026-10-20T22:08:03.4359476Z |
| 2026-09-13 – 2026-09-13 | 1 | 2026-10-20T22:08:03.4359476Z |
| 2026-09-12 – 2026-09-12 | 8 | 2026-10-20T22:08:03.4359476Z |
| 2026-09-11 – 2026-09-11 | 23 | 2026-10-20T22:08:03.4359476Z |
| 2026-09-10 – 2026-09-10 | 45 | 2026-10-20T22:08:03.4359476Z |
| 2026-09-09 – 2026-09-09 | 4 | 2026-10-20T22:08:03.4359476Z |
| 2026-09-08 – 2026-09-08 | 129 | 2026-10-20T22:08:03.4359476Z |
| 2026-09-07 – 2026-09-07 | 6 | 2026-10-20T22:08:03.4359476Z |
| 2026-09-06 – 2026-09-06 | 3 | 2026-10-20T22:08:03.4359476Z |
| 2026-09-04 – 2026-09-04 | 21 | 2026-10-20T22:08:03.4359476Z |
| 2026-09-03 – 2026-09-03 | 23 | 2026-10-20T22:08:03.4359476Z |
| 2026-09-02 – 2026-09-02 | 36 | 2026-10-20T22:08:03.4359476Z |
| 2026-09-01 – 2026-09-01 | 18 | 2026-10-20T22:08:03.4359476Z |
| 2026-08-31 – 2026-08-31 | 2 | 2026-10-20T22:08:03.4359476Z |
| 2026-08-29 – 2026-08-29 | 4 | 2026-10-20T22:08:03.4359476Z |
| 2026-08-28 – 2026-08-28 | 4 | 2026-10-20T22:08:03.4359476Z |
| 2026-08-27 – 2026-08-27 | 18 | 2026-10-20T22:08:03.4359476Z |
| 2026-08-25 – 2026-08-25 | 3 | 2026-10-20T22:08:03.4359476Z |
| 2026-08-24 – 2026-08-24 | 66 | 2026-10-20T22:08:03.4359476Z |
| 2026-08-23 – 2026-08-23 | 3 | 2026-10-20T22:08:03.4359476Z |
| 2026-08-21 – 2026-08-21 | 67 | 2026-10-20T22:08:03.4359476Z |
| 2026-08-20 – 2026-08-20 | 30 | 2026-10-20T22:08:03.4359476Z |
| 2026-08-18 – 2026-08-18 | 23 | 2026-10-20T22:08:03.4359476Z |
| 2026-08-17 – 2026-08-17 | 5 | 2026-10-20T22:08:03.4359476Z |
| 2026-08-15 – 2026-08-15 | 3 | 2026-10-20T22:08:03.4359476Z |
| 2026-08-14 – 2026-08-14 | 4 | 2026-10-20T22:08:03.4359476Z |
| 2026-08-13 – 2026-08-13 | 2 | 2026-10-20T22:08:03.4359476Z |
| 2026-08-12 – 2026-08-12 | 9 | 2026-10-20T22:08:03.4359476Z |
| 2026-08-11 – 2026-08-11 | 103 | 2026-10-20T22:08:03.4359476Z |
| Version | Published | Direct dependencies | Open version |
|---|---|---|---|
| 0.1.0 | 8 Sept 2026 | 2 |
This describes our collected data; it is not a security assessment.
Observed since 20 Oct, 17:51 UTC
No superseded metadata states collected. Unchanged observations do not create new revisions.
package:254b32659bab22d881c5ac90e6eeeb3eac01bde0e8e224d5a48bfeebb4e65d1f