Minimal engine to execute python code generated by LLMs, with a lot of customisation options.
Project description
exec-python
Minimal engine to execute python code generated by LLMs, with a lot of customisation options.
Requirements
- Python 3.13+
- uv (for development & testing)
Installation
pip install exec-python
Running the tests
uv run test_engine.py
Usage
Quick Start
from exec_python import execute_python_code
def pair_sum(x: list[int], y: list[int]) -> list[int]:
assert isinstance(x, list)
assert isinstance(y, list)
assert len(x) == len(y)
return [x[i] + y[i] for i in range(len(x))]
code = """
x = [1, 2]
y = [2, 3]
z = pair_sum(x, y)
k = pair_sum(z, z)
"""
results = execute_python_code(
code = code,
functions=[pair_sum]
)
print(results)
Running the above code will output:
{
"function_results": {
"pair_sum": ["z","k"]
},
"variables": {
"x": [1,2],
"y": [2,3],
"z": [3,5],
"k": [6,10]
},
"errors": []
}
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
exec_python-0.1.3.tar.gz
(14.1 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
File details
Details for the file exec_python-0.1.3.tar.gz.
File metadata
- Download URL: exec_python-0.1.3.tar.gz
- Upload date:
- Size: 14.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.5.15
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
bee8ad10d8ffa5c9f6b232f4ded166b45096b3538fab112c90f5451ca37cb810
|
|
| MD5 |
56ba43fc50b632e98652f17d8cc207f2
|
|
| BLAKE2b-256 |
55ceef6f0fb16c8db199fb3e123a5f35cbb22ec779b213458d0f2fddabc0055c
|
File details
Details for the file exec_python-0.1.3-py3-none-any.whl.
File metadata
- Download URL: exec_python-0.1.3-py3-none-any.whl
- Upload date:
- Size: 4.8 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.5.15
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
b1be708262868341b6e0b697a711ae099de9d5c24900ab450f07d89a903085ec
|
|
| MD5 |
8e823ec420cb45ec5633e65db34cf56f
|
|
| BLAKE2b-256 |
f5038af9cef440d03615b88b66b1a9a4592d3cd1c4ece6742351b797d6ca0c67
|