Metadata-Version: 2.4
Name: dynamic-expressions
Version: 0.2.3
License: MIT
Project-URL: Repository, https://github.com/1PaCHeK1/dynamic-expressions
Classifier: License :: OSI Approved :: MIT License
Requires-Python: >=3.12
Description-Content-Type: text/markdown
Provides-Extra: cache-redis
Requires-Dist: redis>=5.2.1; extra == "cache-redis"
Provides-Extra: serialization-pydantic
Requires-Dist: pydantic>=2.10.6; extra == "serialization-pydantic"
Provides-Extra: serialization-msgspec
Requires-Dist: msgspec>=0.19.0; extra == "serialization-msgspec"

# Dynamic-Expressions

A Python library for building, evaluating, and serializing expression trees.

[Documentation](https://1pachek1.github.io/dynamic-expressions/)

## Installation

```bash
pip install dynamic-expressions
```

With optional dependencies:

```bash
pip install dynamic-expressions[cache-redis,serialization-pydantic,serialization-msgspec]
```

## Quick example

```python
import asyncio

from dynamic_expressions.dispatcher import VisitorDispatcher
from dynamic_expressions.nodes import BinaryExpressionNode, LiteralNode
from dynamic_expressions.types import EmptyContext
from dynamic_expressions.visitors import BinaryExpressionVisitor, LiteralVisitor

dispatcher = VisitorDispatcher[EmptyContext](
    visitors={
        LiteralNode: LiteralVisitor(),
        BinaryExpressionNode: BinaryExpressionVisitor(),
    },
)

node = BinaryExpressionNode(
    operator="+",
    left=LiteralNode(value=1),
    right=LiteralNode(value=2),
)

async def main() -> None:
    result = await dispatcher.visit(node, None)
    assert result == 3

asyncio.run(main())
```

See the [getting started guide](https://1pachek1.github.io/dynamic-expressions/getting-started/) for more.
