leval
Limited evaluator
Decision gist · record as of 2026-08-14
Yes. Leval is a focused, well-maintained tool with zero dependencies, active development, and no known vulnerabilities. It solves a real security problem—safe dynamic expression evaluation—better than ast.literal_eval() for cases where you need variables and functions. Install it if you need to evaluate user or config expressions safely; skip it if you only need literal Python values.AI-flagged interpretation of the facts on this page — verify before relying
Before you install
- Requires Python 3.8 or later.
- Very low friction: pure Python wheel with no runtime dependencies, and actively maintained with a release on 2026-08-13.
License · maintenance · safety
MIT (permissive) — MIT license permits commercial and private use with minimal restrictions, requiring only attribution.
last release 2026-08-13 (1 days) · last repo commit 2026-08-13 · 3 stars
0 known vulnerabilities (OSV.dev, 2026-08-14) · 181,868 downloads/mo, #10,112 on PyPI
Alternatives
Verify before relying
from leval.simple import simple_eval
assert simple_eval('1 + 2') == 3
assert simple_eval('x < -80 or x > 125 or x == 85', values={'x': 85})
assert simple_eval('abs(x) > 80', values={'x': -85}, functions={'abs': abs})- Real-world performance characteristics when evaluating deeply nested or complex expressions.
- Whether max_time enforcement is sufficient for your threat model, given it is cooperative rather than preemptive.
What it is and what it does
Leval is a Python expression evaluator designed to be safer and more flexible than ast.literal_eval() while remaining sandboxed. It parses expressions into an AST and walks it in pure Python, never using getattr or subscripting outside your control. You define which functions and variables are available, and can enforce depth and time limits on evaluation.
The package offers two APIs: a simple_eval() function for straightforward cases (arithmetic, comparisons, function calls with your registered functions), and an advanced API with subclassable Evaluator and Universe classes for custom evaluation rules. Security depends entirely on what you register—any function you provide can be called with attacker-controlled arguments, and operators invoke dunder methods on your values, so avoid registering functions with side effects or objects with dangerous comparisons.
Use it for
- Evaluate user-supplied mathematical or logical expressions in web forms or configuration files without executing arbitrary code.
- Build a formula engine for applications where users define calculations with controlled variables and functions.
- Implement conditional rule evaluation in data pipelines where expressions reference row values but cannot access the filesystem or network.
- Parse and evaluate templated expressions in configuration systems with bounded complexity and execution time.
Worth the install?
AI-flagged interpretation of the facts on this page. Verify before relying on it.
Yes.
Leval is a focused, well-maintained tool with zero dependencies, active development, and no known vulnerabilities. It solves a real security problem—safe dynamic expression evaluation—better than ast.literal_eval() for cases where you need variables and functions. Install it if you need to evaluate user or config expressions safely; skip it if you only need literal Python values.
Install
leval on PyPI
Before you install
Very low friction: pure Python wheel with no runtime dependencies, and actively maintained with a release on 2026-08-13.
Requires Python 3.8 or later.
License in practice
MIT license permits commercial and private use with minimal restrictions, requiring only attribution.
Quickstart
from leval.simple import simple_eval
assert simple_eval('1 + 2') == 3
assert simple_eval('x < -80 or x > 125 or x == 85', values={'x': 85})
assert simple_eval('abs(x) > 80', values={'x': -85}, functions={'abs': abs})
Verify before relying
- Real-world performance characteristics when evaluating deeply nested or complex expressions.
- Whether max_time enforcement is sufficient for your threat model, given it is cooperative rather than preemptive.
Package facts
| License | MIT permissive |
| Python support | Supports the current Python release >=3.8 |
| Install friction | Low. Pure-Python wheel |
| Runtime dependencies | None |
| Maintenance | Actively maintained 1 days since the last release |
| Last repo commit | |
| First released | |
| Downloads | 181,868 / month, #10,112 on PyPI 30-day window, as of 2026-08-14 |
| Known vulnerabilities | None known OSV.dev, checked 2026-08-14 |
Evidence: leval-1.4.0-py3-none-any.whl
Tags
Let your AI agent find packages like this
Example. Real query, live index.
You found this page by searching. An agent finds it by wishing: SkillFed indexes 14,416 PyPI packages by what they can do, searchable in plain language.
wish › “safe expression evaluation”
- levalLeval evaluates limited expressions safely by parsing them into an…
- common-expression-languageEvaluates Google's Common Expression Language (CEL) expressions in…
- astevalAsteval is a safe Python expression and statement evaluator that uses…
Give your agent the search over MCP, or paste the wish link into any chat.
More Software Development packages
Provides backported and experimental type hints for Python 3.9+, allowing use of newer typing features on older Python versions and enabling early experimentation with type system PEPs before they enter the standard library.
NumPy provides an N-dimensional array object and a comprehensive suite of mathematical, linear algebra, Fourier transform, and random number functions for scientific computing in Python.
FastAPI is a Python web framework for building REST APIs using type hints, with automatic request validation, serialization, and interactive API documentation.
Provides a way to document function parameters, class attributes, return types, and variables inline using Python's `Annotated` type hint syntax instead of traditional docstrings.
Typer builds command-line applications from Python functions using type hints, automatically generating help text, argument parsing, and shell completion.
Install it if you are building CLIs in Python.
Distlib provides low-level packaging utilities for building, distributing, and managing Python software—including metadata handling, version specifiers, wheel support, script installation, and dependency resolution.
See also asteval · simpleeval · pure-eval · py-expression-eval · cel-python · common-expression-language · tag-expressions · autoevals · trampoline · bddl