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.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.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| caj-0.0.1.tar.gz | 5.1 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| caj-0.0.1-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 11.8 kB
Release files / caj-0.0.1.tar.gz
| Download URL | caj-0.0.1.tar.gz |
|---|---|
| Size | 5.1 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
64155e7fbf23f0d0730600dc26b47d2e125762f483cbdd1b873d5e66b9485e54
|
|
BLAKE2b-256 checksum How to use checksums |
09d87ff5a6a01f1f3b2a292d33055c6acdb8af1b4ae6b5e5c047744931a6dc84
|
| 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.1-py3-none-any.whl
| Download URL | caj-0.0.1-py3-none-any.whl |
|---|---|
| Size | 6.8 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
ccbf5a2d52f3babc72b29fc936fdb8e3242db34f3efd263b29439336595b6158
|
|
BLAKE2b-256 checksum How to use checksums |
ee3f421ccf526c5696023294a2a21e63f227f8d65f1764e81d312bff5e5a436f
|
| 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}
|