Instantiate and invoke WebAssembly modules
masterTo run a WebAssembly module, use pywasm.core.Runtime to create a runtime instance. You can instantiate modules directly from a file using the instance_from_file method. Once instantiated, use invocate to call specific exported functions from the module.
Note: invocate returns a list/tuple of results, so access the desired return value via index (e.g., r[0]).
import pywasm
pywasm.log.lvl = 1
runtime = pywasm.core.Runtime()
# Load the module from a file path
m = runtime.instance_from_file('example/fibonacci/bin/fibonacci.wasm')
# Call the 'fibonacci' function with argument [10]
r = runtime.invocate(m, 'fibonacci', [10])
print(f'fibonacci(10) = {r[0]}')