Extremely simple to use callable memoization decorator library.
Project description
belljar 🫙
Conditional memoization for complex runtime state.
Standard decorators check the cache before execution. belljar lets you check the cache during execution.
By calling includes(), you update the hash with runtime state (like file handles or database cursors). If belljar detects that this specific state has been processed before, execution stops immediately and the cached result is returned.
Usage
from belljar import jar, includes
@jar
def parse_log(file_handle):
# 1. State is initially just the function args.
# 2. Add runtime state to the hash (e.g., file cursor position).
includes(file_handle)
# CHECKPOINT:
# If this exact sequence (args + file state) exists in the cache,
# execution STOPS here and returns the stored value.
print("Heavy processing...")
return file_handle.read()
Features
- Mid-Execution Cache Hits: Skip the heavy lifting if the intermediate state is recognized.
- Complex Serialization: Uses
dillinstead ofpickle, supporting lambdas, local classes, and closures. - Zero Config: caches to
.jar/by default, or pass a path:@jar(Path("/tmp/cache")).
Installation
uv add belljar
# or
pip install belljar
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file belljar-0.1.2.tar.gz.
File metadata
- Download URL: belljar-0.1.2.tar.gz
- Upload date:
- Size: 2.4 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.9.26 {"installer":{"name":"uv","version":"0.9.26","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Arch Linux","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
c3afdf0ec4752794dffc035f57c88890971c51fd078d6ffef805cfa04070366b
|
|
| MD5 |
0635097bcfb699a024ff8fdc5146475b
|
|
| BLAKE2b-256 |
cbf17cb24730ef17d60cffbd5e9742a3c137c7c2ffee05939fc52f4369e12e3d
|
File details
Details for the file belljar-0.1.2-py3-none-any.whl.
File metadata
- Download URL: belljar-0.1.2-py3-none-any.whl
- Upload date:
- Size: 3.0 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.9.26 {"installer":{"name":"uv","version":"0.9.26","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Arch Linux","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
e057c111fd163e26e00c4acbde616c9caceafcb9299bf20a3685bc97eae7eff6
|
|
| MD5 |
ba2ae595f4543023bbd84d7bc98304d5
|
|
| BLAKE2b-256 |
df3389f787a4590d7b91726a51a2b8ddc7f42484d9cd6a256a03a826753dddc9
|