Skip to main content

WebAssembly-powered, sandboxed implementation of Python runtime for safely exec()-cuting dynamic Python code.

Project description

wasm-runtime

WebAssembly-powered, sandboxed implementation of Python runtime for safely exec()-cuting dynamic Python code.

This is an active version of wasm_exec created by Justin Flick.
See Jflick58/wasm_exec/LICENSE and ● wasm_runtime/LICENSE.

$ pip install wasm-runtime


Use

from wasm_runtime import WasmRuntime

runtime = WasmRuntime()
result = runtime.exec("print('Hi, Mom!')")

print(result)
# Result(stdout='Hi, Mom!\n', stderr='', ...)

class WasmRuntime

__init__(
    self, 
    use_fuel: bool = False, 
    fuel: int = 400_000_000, 
    runtime_path: str = ""
)

Creates a new instance of WebAssembly runtime.

Original code by Justin Flick.

Args:

  • use_fuel (bool): Whether to use fuel.
  • fuel (int): Fuel.
  • runtime_path (str): Runtime path. If not specified, the runtime will be downloaded automatically.

def exec

exec(self, code: str) -> Result

Execute Python code.

Args:

  • code (str): Python code.

dataclass Result

stdout: str
stderr: str
memory_size: int
data_len: int
fuel_consumed: int

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

wasm-runtime-0.2.tar.gz (4.8 kB view details)

Uploaded Source

File details

Details for the file wasm-runtime-0.2.tar.gz.

File metadata

  • Download URL: wasm-runtime-0.2.tar.gz
  • Upload date:
  • Size: 4.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.0.0 CPython/3.11.9

File hashes

Hashes for wasm-runtime-0.2.tar.gz
Algorithm Hash digest
SHA256 431f9530e3dbf1bfcd2bc93997e6092198131197b4457199109d1b79d7792b55
MD5 7e984fcefa4e4cb4c83dfc98fb634dd8
BLAKE2b-256 7d7ad01f4ebb5fda2f64be741d041e72fbddbebbde103bb5b4e9d7ee0b443a1b

See more details on using hashes here.

Supported by

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