Skip to main content

A library for lazy evaluation with context caching

Project description

lazily

A Python library for lazy evaluation with context caching.

Installation

pip install lazily

Example usage

from lazily import cell, slot


@cell
def name(ctx: dict) -> str:
    return "World"


@slot
def greeting(ctx: dict) -> str:
    print("Calculating...")
    return f"Hello, {name(ctx).value}!"


ctx = {}

# First access: runs the function
greeting(ctx)
# Calculating...
# 'Hello, World!'

# Second access: uses cache (no print)
greeting(ctx)
# 'Hello, World!'

# Update cell: invalidates cache
name(ctx).value = "Lazily"

# Access again: re-runs the function
greeting(ctx)
# Calculating...
# 'Hello, Lazily!'

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

lazily-0.4.1.tar.gz (15.6 kB view details)

Uploaded Source

Built Distribution

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

lazily-0.4.1-py3-none-any.whl (12.1 kB view details)

Uploaded Python 3

File details

Details for the file lazily-0.4.1.tar.gz.

File metadata

  • Download URL: lazily-0.4.1.tar.gz
  • Upload date:
  • Size: 15.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.14.0

File hashes

Hashes for lazily-0.4.1.tar.gz
Algorithm Hash digest
SHA256 82b303d52668e822578f0af5a96498a7b789885783aeffb68ea2f842bb5c75fc
MD5 f2c5fc68bff7adf13fb60cd10acff13a
BLAKE2b-256 c62a1d601bc7859a2e375da34affd0e995378001ebfc207fc44a23fd22660eab

See more details on using hashes here.

File details

Details for the file lazily-0.4.1-py3-none-any.whl.

File metadata

  • Download URL: lazily-0.4.1-py3-none-any.whl
  • Upload date:
  • Size: 12.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.14.0

File hashes

Hashes for lazily-0.4.1-py3-none-any.whl
Algorithm Hash digest
SHA256 f0c3691abf4903a404664d1114cb1d23ef0720e79c4206458904fef851fc364d
MD5 70695af7bf50e8fffd675f307b724c8a
BLAKE2b-256 6dfdcfeec653d17a0da918dd396652381fc738cb5af99efc1dbc918412124b22

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