Skip to main content
caj

Automatic persistent caching for JAX function invocations

CI Codecov Ruff ty uv Publish PyPI PyPI - Python Version

caj is a simple persistent cache for JAX-based code.

Decorate a function with @cache, and caj will store the return on disk. Later calls with the same inputs will load the result directly from the cache instead of performing the computation again.

import jax
import jax.numpy as jnp
from caj import cache


@cache
@jax.jit
def compute(x):
    return jnp.linalg.eigvalsh(x)


x = jnp.eye(1000)

y = compute(x)

Running the above code twice will only compute the eigenvalues once: the second time, caj will just load the result from disk.

caj takes advantage of the computation tracing provided by JAX so it can detect changes in the decorated function or any other functions it calls and not return cached results that were computed with different code.

Installation

Install caj from PyPI:

pip install caj

Usage

For most uses, the default cache is enough:

from caj import cache


@cache
def f(x): ...

By default, caj stores entries in a per-user cache directory and limits the cache to 1 GB.

A custom cache directory can be specified with dir:

@cache(dir=".cache")
def f(x): ...

The maximum size of a custom cache can also be configured via max_bytes:

@cache(dir=".cache", max_bytes=2_000_000_000)
def f(x): ...

Or, set max_bytes=None for no size limit:

@cache(dir=".cache", max_bytes=None)
def f(x): ...

When a size limit is enabled, caj will remove the least recently used entries as necessary to keep the cache within the target size.

Metadata

Release files for caj 0.0.3

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for caj 0.0.3
File Size Uploaded Provenance Actions
caj-0.0.3.tar.gz 5.6 kB Without provenance Details for caj-0.0.3.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for caj 0.0.3
File Interpreter ABI Platform Actions
caj-0.0.3-py3-none-any.whl Python 3 none any Details for caj-0.0.3-py3-none-any.whl

Total release size: 12.6 kB

Release files / caj-0.0.3.tar.gz

Download URL caj-0.0.3.tar.gz
Size 5.6 kB
Tags Source
SHA-256 checksum
How to use checksums
5930f4fe60464a756aa31e921da5c987a4cc36c74ee27baa1c17018b5dabe141
BLAKE2b-256 checksum
How to use checksums
1d4d39bae21f131745662ee79197910a04c84d56b43920dd176f9b3429d63a10
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via uv/0.12.23 {"installer":{"name":"uv","version":"0.12.23","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

Release files / caj-0.0.3-py3-none-any.whl

Download URL caj-0.0.3-py3-none-any.whl
Size 7.0 kB
Tags Python 3
SHA-256 checksum
How to use checksums
e2aceafd9dfaea7676cb9148596ad995490cf2b2fc8d1991bae30b33b230e9c5
BLAKE2b-256 checksum
How to use checksums
c4d7a1d322f2b653fe420b7a3144d4098640e54aaf7f27ecf319f5c3145b0342
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via uv/0.12.23 {"installer":{"name":"uv","version":"0.12.23","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

Security for caj 0.0.3

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page