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.5.tar.gz
(15.0 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.5.tar.gz.
File metadata
- Download URL: exec_python-0.1.5.tar.gz
- Upload date:
- Size: 15.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.5.15
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
60b3bfd8be351e6a81d88285a7275b6ca92b9fee28baed6fe7190e94579dfa5b
|
|
| MD5 |
a097a7e443f7a6e61ee8e96c2aad3d04
|
|
| BLAKE2b-256 |
e86589f112aa84bb2dc9d850879a22cbb5d4a5f7f02a248201726c6512c5d1e5
|
File details
Details for the file exec_python-0.1.5-py3-none-any.whl.
File metadata
- Download URL: exec_python-0.1.5-py3-none-any.whl
- Upload date:
- Size: 5.0 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.5.15
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
24b062c447655f34d16e82ca39c7bbe3be481a3e91f142d62dd70fcfa37f7357
|
|
| MD5 |
ea8dd423cb495a9eb4a357fd51bae266
|
|
| BLAKE2b-256 |
cc08a365da5f0c3234dd3427e10c9f65d293bba671f679a47ca4601f840abfc9
|