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.2

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.2
File Size Uploaded Provenance Actions
caj-0.0.2.tar.gz 5.5 kB Without provenance Details for caj-0.0.2.tar.gz

Built distribution (wheel)

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

Total release size: 12.4 kB

Release files / caj-0.0.2.tar.gz

Download URL caj-0.0.2.tar.gz
Size 5.5 kB
Tags Source
SHA-256 checksum
How to use checksums
ff1946d38a934ca83fc0480c6786b99d3bc0b8e3478aae7daba661a4bf5e24a9
BLAKE2b-256 checksum
How to use checksums
a9fe2f182f84c50c334788ce03d3f7daadaa87c965ebe0a5e69b1525de6e5eca
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.2-py3-none-any.whl

Download URL caj-0.0.2-py3-none-any.whl
Size 6.9 kB
Tags Python 3
SHA-256 checksum
How to use checksums
b44e919dd513392f33427654eefdc3526b175b61882459ebab7b00c80dc37d95
BLAKE2b-256 checksum
How to use checksums
b00b4826d08351d51070ad6ffa3eb762aaf298c960b33e5831693281fdc4339f
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.2

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