Skip to main content

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, import_functions

functions = """
def pair_sum(x: List[int], y: List[int]) -> List[int]:
    return x + y
"""

code = """
x = [1, 2]
y = [2, 3]
z = pair_sum(x, y)
k = pair_sum(z, z)
"""

results = execute_python_code(
    code = code,
    functions=import_functions(functions),
)
print(results)

Running the above code will output:

{
  "function_results": {
    "pair_sum": ["z","k"]
  },
  "variables": {
    "x": [1,2],
    "y": [2,3],
    "z": [1,2,2,3],
    "k": [1,2,2,3,1,2,2,3]
  },
  "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.2.tar.gz (8.7 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

exec_python-0.1.2-py3-none-any.whl (4.7 kB view details)

Uploaded Python 3

File details

Details for the file exec_python-0.1.2.tar.gz.

File metadata

  • Download URL: exec_python-0.1.2.tar.gz
  • Upload date:
  • Size: 8.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.5.15

File hashes

Hashes for exec_python-0.1.2.tar.gz
Algorithm Hash digest
SHA256 ab7210709f8eeda946b05bc3795c4ae9f246b5f76e991d596269ee4597a2ec3d
MD5 824ecc341c73e9b3156adc2d867e9222
BLAKE2b-256 b8bf53c8f94ec667c3eaa220b717b61f0435baadce7e0e6ef937e6575ae88ac5

See more details on using hashes here.

File details

Details for the file exec_python-0.1.2-py3-none-any.whl.

File metadata

File hashes

Hashes for exec_python-0.1.2-py3-none-any.whl
Algorithm Hash digest
SHA256 0c0658ae52324552b8ebaa7660ae29b3dc80890072d8efc01e7e111f29a5522b
MD5 1a05a131511646c1e23e48188b46fe7f
BLAKE2b-256 4dcbe3841184496a39d31bf3cb2336bc359b2a5e125585ac0d04cef9bef74a2c

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page