A symbolic DSL for crafting concise Python lambda expressions.
Project description
lmbd
A lightweight library for creating lambda expressions in Python using a symbolic syntax.
Installation
pip install lmbd
Quick Start
from lmbd import _, F
# Create a lambda that adds 1
add_one = F(_ + 1)
print(add_one(5)) # 6
# Use multiple arguments
add = F(_ + _)
print(add(1, 2)) # 3
# Positional arguments with P
from lmbd import P
custom_add = F(P[0] + P[1] * 2)
print(custom_add(10, 5)) # 20
# Keyword arguments
greet = F("Hello, " + P["name"])
print(greet(name="Alice")) # Hello, Alice
F prevents ambiguity. It ensures __call__ triggers a functional call within the expression instead of executing the placeholder prematurely.
from lmbd import _
assert F(_.upper())('test') == 'TEST'
from lmbd.auto import _
print((_ + 1)(5)) # 6
print((_.upper())('test')) # ❌ This raises error since `_.upper` is treated as a placeholder, and `()` immediately invokes it with no arguments.
Under the Hood
Placeholder expressions maintain an AST and are compiled into a callable objects only when invoked. This design balances a flexible DSL with Python's native execution efficiency.
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 lmbd-0.1.1.tar.gz.
File metadata
- Download URL: lmbd-0.1.1.tar.gz
- Upload date:
- Size: 3.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.10.2 {"installer":{"name":"uv","version":"0.10.2","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 |
a5b07ce1faa1b665baa386603a6af518ee746738bd0befee255f0933f9da0e6e
|
|
| MD5 |
a4d9b89f493247d2e73ccf36f282ef7e
|
|
| BLAKE2b-256 |
d83bce471e8d75b8a426982f89aed2597ec340beed098123f8aef5d63a105179
|
File details
Details for the file lmbd-0.1.1-py3-none-any.whl.
File metadata
- Download URL: lmbd-0.1.1-py3-none-any.whl
- Upload date:
- Size: 4.2 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.10.2 {"installer":{"name":"uv","version":"0.10.2","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 |
ea44fc46adff5d5294f99a0521e784a04237bf78c234e2d0c5beedacf10deebd
|
|
| MD5 |
91a52ec09e4c983c8b471bd78b313998
|
|
| BLAKE2b-256 |
697169342ee098e28011a45ad8d0280e895ec41e26b71c92cda6056ec5b1027e
|