{"id":16499190,"url":"https://github.com/hardbyte/python-common-expression-language","last_synced_at":"2026-02-08T04:13:51.605Z","repository":{"id":231858939,"uuid":"782885993","full_name":"hardbyte/python-common-expression-language","owner":"hardbyte","description":"Python wrapper of a Rust CEL implementation","archived":false,"fork":false,"pushed_at":"2025-08-03T11:27:09.000Z","size":2069,"stargazers_count":2,"open_issues_count":1,"forks_count":0,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-08-04T03:11:29.516Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/hardbyte.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2024-04-06T10:18:12.000Z","updated_at":"2025-08-01T23:47:02.000Z","dependencies_parsed_at":"2024-11-11T12:24:51.337Z","dependency_job_id":"4860019f-8657-4c69-aa17-1b73841c9ea0","html_url":"https://github.com/hardbyte/python-common-expression-language","commit_stats":null,"previous_names":["hardbyte/python-common-expression-language"],"tags_count":5,"template":false,"template_full_name":null,"purl":"pkg:github/hardbyte/python-common-expression-language","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hardbyte%2Fpython-common-expression-language","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hardbyte%2Fpython-common-expression-language/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hardbyte%2Fpython-common-expression-language/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hardbyte%2Fpython-common-expression-language/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/hardbyte","download_url":"https://codeload.github.com/hardbyte/python-common-expression-language/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hardbyte%2Fpython-common-expression-language/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":269400186,"owners_count":24410924,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-08-08T02:00:09.200Z","response_time":72,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-10-11T14:51:28.324Z","updated_at":"2026-02-08T04:13:51.600Z","avatar_url":"https://github.com/hardbyte.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Python CEL - Common Expression Language\n\n[![Documentation](https://img.shields.io/badge/docs-readthedocs-blue)](https://python-common-expression-language.readthedocs.io/)\n[![PyPI version](https://badge.fury.io/py/common-expression-language.svg)](https://pypi.org/project/common-expression-language/)\n[![Python 3.11+](https://img.shields.io/badge/python-3.11+-blue.svg)](https://www.python.org/downloads/)\n\n**Fast, Safe, and Expressive evaluation of Google's Common Expression Language (CEL) in Python, powered by Rust.**\n\nThe Common Expression Language (CEL) is a non-Turing complete language designed for simplicity, speed, and safety. This Python package wraps the Rust implementation [cel-interpreter](https://crates.io/crates/cel-interpreter) v0.10.0, providing microsecond-level expression evaluation with seamless Python integration.\n\n## 🚀 Use Cases\n\n- 🛡️ **Policy Enforcement**: Define access control rules that can be updated without code changes\n- ⚙️ **Configuration Validation**: Validate complex settings with declarative rules  \n- 🔄 **Data Transformation**: Transform and filter data with safe, portable expressions\n- 📋 **Business Rules**: Implement decision logic that business users can understand\n- 🔍 **Query Filtering**: Build dynamic filters for databases and APIs\n- 🎯 **Feature Flags**: Create sophisticated feature toggle conditions\n\n## Installation\n\n```bash\npip install common-expression-language\n```\n\nOr using uv:\n```bash\nuv add common-expression-language\n```\n\nAfter installation, both the Python library and the `cel` command-line tool will be available.\n\n\u003e 📖 **Full Documentation**: https://python-common-expression-language.readthedocs.io/\n\n## Quick Start\n\n### Python API\n\n```python\nfrom cel import evaluate\n\n# Simple expressions\nresult = evaluate(\"1 + 2\")  # 3\nresult = evaluate(\"'Hello ' + 'World'\")  # \"Hello World\"\nresult = evaluate(\"age \u003e= 18\", {\"age\": 25})  # True\n\n# Complex expressions with context\nresult = evaluate(\n    'user.role == \"admin\" \u0026\u0026 \"write\" in permissions',\n    {\n        \"user\": {\"role\": \"admin\"},\n        \"permissions\": [\"read\", \"write\", \"delete\"]\n    }\n)  # True\n```\n\n### Command Line Interface\n\n```bash\n# Simple evaluation\ncel '1 + 2'  # 3\n\n# With context\ncel 'age \u003e= 18' --context '{\"age\": 25}'  # true\n\n# Interactive REPL\ncel --interactive\n```\n\n### Pre-compilation for Performance\n\nWhen evaluating the same expression multiple times with different contexts, use `compile()` for better performance:\n\n```python\nimport cel\n\n# Compile once\nprogram = cel.compile(\"price * quantity \u003e threshold\")\n\n# Execute many times - much faster than repeated evaluate() calls\nresult1 = program.execute({\"price\": 10, \"quantity\": 5, \"threshold\": 40})  # True\nresult2 = program.execute({\"price\": 5, \"quantity\": 3, \"threshold\": 20})   # False\n```\n\n### Custom Functions\n\n```python\nfrom cel import Context, evaluate\n\ndef calculate_discount(price, rate):\n    return price * rate\n\ncontext = Context()\ncontext.add_function(\"calculate_discount\", calculate_discount)\ncontext.add_variable(\"price\", 100)\n\nresult = evaluate(\"price - calculate_discount(price, 0.1)\", context)  # 90.0\n```\n\n### Real-World Example\n\n```python\nfrom cel import evaluate, Context\n\n# Access control policy\npolicy = \"\"\"\nuser.role == \"admin\" || \n(resource.owner == user.id \u0026\u0026 current_hour \u003e= 9 \u0026\u0026 current_hour \u003c= 17)\n\"\"\"\n\ncontext = Context()\ncontext.update({\n    \"user\": {\"id\": \"alice\", \"role\": \"user\"},\n    \"resource\": {\"owner\": \"alice\"},\n    \"current_hour\": 14  # 2 PM\n})\n\naccess_granted = evaluate(policy, context)  # True\n```\n\n## Features\n\n- ✅ **Fast Evaluation**: Microsecond-level expression evaluation via Rust\n- ✅ **Rich Type System**: Integers, floats, strings, lists, maps, timestamps, durations\n- ✅ **Python Integration**: Seamless type conversion and custom function support\n- ✅ **CLI Tools**: Interactive REPL and batch processing capabilities\n- ✅ **Safety First**: Non-Turing complete, safe for untrusted expressions\n\n## Documentation\n\n📚 **Complete documentation available at**: https://python-common-expression-language.readthedocs.io/\n\n\n### Building Documentation Locally\n\nTo build and serve the documentation locally:\n\n```bash\n# Install documentation dependencies\nuv sync --group docs\n\n# Build the documentation\nuv run --group docs mkdocs build\n\n# Serve locally with live reload\nuv run --group docs mkdocs serve\n```\n\nThe documentation will be available at http://localhost:8000\n\n## Development\n\n### Testing\n\n```bash\n# Run all tests\nuv run pytest\n\n# Run with coverage\nuv run pytest --cov=cel\n\n# Test all documentation examples (embedded code + standalone files)\nuv run --group docs pytest tests/test_docs.py -v\n```\n\n### Building from Source\n\n```bash\n# Install development dependencies\nuv sync --dev\n\n# Build the package\nuv run maturin develop\n\n# Run tests\nuv run pytest\n```\n\n## Contributing\n\nContributions are welcome! Please see our [documentation](https://python-common-expression-language.readthedocs.io/) for:\n- [CEL compliance status](docs/reference/cel-compliance.md)\n- Development setup and guidelines\n- Areas where help is needed\n\n## License\n\nThis project is licensed under the same terms as the original cel-interpreter crate.\n\n## Resources\n\n- [📖 **Documentation**](https://python-common-expression-language.readthedocs.io/)\n- [🌐 **CEL Homepage**](https://cel.dev/)\n- [📋 **CEL Specification**](https://github.com/google/cel-spec)\n- [⚙️ **cel-interpreter Rust crate**](https://crates.io/crates/cel-interpreter)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhardbyte%2Fpython-common-expression-language","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fhardbyte%2Fpython-common-expression-language","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhardbyte%2Fpython-common-expression-language/lists"}