Skip to content

Repository files navigation

pyjs

CICI

Important Notice

The main branch is already using emscripten >=4.x and the experimental channel https://prefix.dev/channels/emscripten-forge-4x. The old emscripten 3.1.73 based branch is available at https://github.com/emscripten-forge/pyjs/tree/emscripten-3.1.73

What is pyjs

pyjs is modern pybind11 + emscripten Embind based Python <-> JavaScript foreign function interface (FFI) for wasm/emscripten compiled Python.

The API is loosly based on the FFI of pyodide.

Full Documentation

See the documentation for a full documentation.

Try it out

Quickstart

Access Javascript from Python:

importpyjs# hello world pyjs.js.console.log("Hello, World!")
# create a JavaScript function to add two numbersjs_function=pyjs.js.Function("a", "b", """ console.log("Adding", a, "and", b) return a + b""")
# call the functionresult=js_function(1, 2)

Access Python from Javascript:

// hello worldpyjs.eval("print('Hello, World!')")// eval a python expression and get the resultconstpy_list=pyjs.eval("[i for i in range(10)]")/// access console.log(py_list.get(0))// same as py_list[0] on the python side

About

Python ⇔ JavaScript bindings using high level embind and pybind11

Topics

Resources

Stars

30 stars

Watchers

5 watching

Forks

Releases

Packages

Used by

Contributors

Languages