Skip to content

4 Questions \ Concerns \ Challenges

Eric Snow edited this page Aug 28, 2018 · 1 revision

Summary

  1. general
    • Web vs. not Web
  2. interop
    • How to expose Python in JS/TS?
    • How to expose JS/TS in Python?
  3. runtime
    • What part of runtime is unsupported?
    • Performance Penalty
  4. modules
    • What stdlib modules are unavailable?
    • .py/extension import won't work without adding an importer that can handle JS sandbox
    • How to provide stdlib?
    • How to support Python (.py) modules?
    • How to support extension modules?
  5. Python server
    • Interact via Socket vs. stdio
    • Lifecycle Management
    • JS/TS API
    • Python API

General

Web vs. not Web

...

Interop

Prior Art:

  • Jython
  • IronPython
  • brython
  • batavia
  • transcrypt
  • ...

How to expose Python in JS/TS?

  • "py" JS module: .exec(src: string): any
  • "py" JS module: .run(argv, ...) (a la subprocess)
  • "py" JS module: .import(module: string): Module (expose module attrs to JS)
  • native JS modules / objects
  • ...

How to expose JS/TS in Python?

  • "js" (or "ts") Python module to expose JS globals
  • "js" Python module: .require(module) (expose JS module to Python)
  • ...

Runtime

Prior art:

  • brython
  • transcrypt
  • batavia
  • micropython
  • ...

What part of runtime is unsupported?

  • subinterpreters?
  • threads?
  • subprocesses?

Performance Penalty

Native JS/WASM will be faster (and use less memory) than artifacts compiled/transpiled from Python.

Modules

Prior art:

  • brython
  • transcrypt
  • batavia
  • micropython
  • ...

What stdlib modules are unavailable?

.py/extension import won't work without adding an importer that can handle JS sandbox

How to provide stdlib?

  • pre-build into Python runtime (i.e. frozen/builtin)
  • ship zipped along with Python (.py only)

How to support Python (.py) modules?

  • pre-build into Python runtime (i.e. frozen)
  • ship zipped along with Python (.py only)

How to support extension modules?

  • pre-build into Python runtime (i.e. builtin)
  • transpile to JS
  • compile to WASM

Python Server

Interact via socket vs. stdio

...

Lifecycle Management

e.g. launch; don't leak processes

JS/TS API

...

Python API

...