Skip to main content

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 include(), 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

import belljar

@belljar.store
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).
    belljar.include(file_handle)

    # CHECKPOINT: 
    # If this exact sequence (args + file state) exists in the cache,
    # execution STOPS here and returns the stored value.
    belljar.check()
    
    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 dill instead of pickle, supporting lambdas, local classes, and closures.
  • Zero Config: caches to .jar/ by default, or pass a path: @store(Path("/tmp/cache")).

Installation

uv add belljar
# or
pip install belljar

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

belljar-1.1.1.tar.gz (2.8 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

belljar-1.1.1-py3-none-any.whl (3.4 kB view details)

Uploaded Python 3

File details

Details for the file belljar-1.1.1.tar.gz.

File metadata

  • Download URL: belljar-1.1.1.tar.gz
  • Upload date:
  • Size: 2.8 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

Hashes for belljar-1.1.1.tar.gz
Algorithm Hash digest
SHA256 bdbac9aa88ef6c3a035b2f742fbab362b0ad0ba5e879cd8b4413d95bc6df21e3
MD5 97ec0724f6885130d2c7b610f5530e44
BLAKE2b-256 3ee42d101ded09b49844cdbf8fa4edc3f7b322c27b4e7da9c721186b6a4bfc1e

See more details on using hashes here.

File details

Details for the file belljar-1.1.1-py3-none-any.whl.

File metadata

  • Download URL: belljar-1.1.1-py3-none-any.whl
  • Upload date:
  • Size: 3.4 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

Hashes for belljar-1.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 b30875af2850b7351ebaab9e6d35caa701641a0d2b314bdeab4824e8760d9e84
MD5 9f5f249caddb745edd2e3f8cefc4972c
BLAKE2b-256 ebc072eebf835f77f35768b7d3ae2339125b11f3590b70f4068080ca70b6c14c

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page