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
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
lazily-0.4.0.tar.gz
(15.6 kB
view details)
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
lazily-0.4.0-py3-none-any.whl
(12.1 kB
view details)
File details
Details for the file lazily-0.4.0.tar.gz.
File metadata
- Download URL: lazily-0.4.0.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
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
82258b84e05b33f8ab0b1b812cf039995de05fdc863a0e4ed7994b1be4f760d5
|
|
| MD5 |
233302a045b441cad7c0f15a7fefc450
|
|
| BLAKE2b-256 |
ad5f2eb1927c5537f5d9f5c66ab449243971ec7de46f0900241ca9421350cb97
|
File details
Details for the file lazily-0.4.0-py3-none-any.whl.
File metadata
- Download URL: lazily-0.4.0-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
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
3bb59dcaa38da0e595dace37bf6e28bb6c2ed283467f0fe8a402b1b8f4ee7a19
|
|
| MD5 |
ea3df206c41d204e5c37da6cc92060c1
|
|
| BLAKE2b-256 |
42f17a24e026ed95ddcea78736dda10010d532788152d0eff7ac46c767db9be9
|