Skip to content
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Add Brython engine (v0.2.0)
New optional engine 'symplex.engine': 'embedded-brython' running SymPy
1.14 on Brython (Python transpiled to JavaScript) in a worker thread —
no Python installation required.

- vendor/brython holds a patched Brython build (see
  vendor/brython/README.md): stock releases up to 3.14.3 silently
  miscompute SymPy results; the fixes are upstream in
  brython-dev/brython#2912. Do not replace with a CDN copy until that
  is merged and released.
- The worker shims a minimal browser environment (Brython targets
  browsers) and a filesystem-backed synchronous XMLHttpRequest that
  serves module imports and unicode.txt from vendor/brython.
- 'npm run fetch-brython-libs' extracts the sympy/mpmath sources into
  vendor/brython/lib (git-ignored) from the same wheels the Pyodide
  engine uses.
- Engines now share the WorkerEngine harness (timeout, idle shutdown,
  crash recovery).

Measured against Pyodide on the same machine: ~8s cold start vs ~1s,
~0.3s warm evaluations vs near-instant, ~640 MB resident vs ~220 MB —
so Pyodide stays the default; Brython is opt-in (its lightness applies
to browser downloads, not to a local extension host).

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
  • Loading branch information
zalo and claude committed Aug 13, 2026
commit 0972293ad2c2abec7387b21b8a7ffb91c0d2eda8
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
out
node_modules
wheels
vendor/brython/lib
.vscode-test/
*.vsix
2 changes: 2 additions & 0 deletions .vscodeignore
Original file line number Diff line number Diff line change
Expand Up @@ -12,5 +12,7 @@ vsc-extension-quickstart.md
**/*.vsix
node_modules/.bin/**
node_modules/@types/**
node_modules/adm-zip/**
node_modules/eslint/**
node_modules/typescript-eslint/**
vendor/brython/lib/**/tests/**
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
# Change Log

## 0.2.0 - Brython Engine

- New optional engine `"symplex.engine": "embedded-brython"`: SymPy 1.14 running on Brython (Python transpiled to JavaScript) inside a worker thread, no Python installation required. Uses the patched Brython build from [brython-dev/brython#2912](https://github.com/brython-dev/brython/pull/2912) vendored in `vendor/brython` (stock Brython releases miscompute SymPy results).
- Engines now share a common worker harness (timeouts, idle shutdown after 5 minutes, crash recovery).

## 0.1.0 - Embedded SymPy + Parser Overhaul

- SymPy 1.14 now runs **inside the extension** via Pyodide (CPython on WebAssembly) — no Python installation required. The old subprocess mode is still available via `"symplex.engine": "system"`.
Expand Down
8 changes: 6 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,15 @@ A Symbolic CAS that operates directly on Javascript and Python code.

None! SymPy 1.14 runs inside the extension via [Pyodide](https://pyodide.org) (CPython compiled to WebAssembly).

If you would rather use a locally installed Python (`pip install sympy`), set `"symplex.engine": "system"` — and point `"symplex.pythonPath"` at your interpreter if it isn't `python3`/`python` on your PATH.
Two alternative engines are available:
- `"symplex.engine": "embedded-brython"` runs SymPy via [Brython](https://brython.info) (Python transpiled to JavaScript) using the patched build in `vendor/brython` (see [brython-dev/brython#2912](https://github.com/brython-dev/brython/pull/2912)). Also requires no Python installation.
- `"symplex.engine": "system"` uses a locally installed Python (`pip install sympy`) — point `"symplex.pythonPath"` at your interpreter if it isn't `python3`/`python` on your PATH.

Measured on the same machine, per engine: Pyodide ~1s cold start, near-instant evaluations, ~220 MB resident; Brython ~8s cold start, ~0.3s evaluations, ~640 MB resident. Both are fully unloaded after 5 idle minutes.

## Settings

- `symplex.engine` — `embedded` (default, Pyodide) or `system` (local Python subprocess).
- `symplex.engine` — `embedded` (default, Pyodide), `embedded-brython` (Brython), or `system` (local Python subprocess).
- `symplex.pythonPath` — interpreter used by the `system` engine.
- `symplex.timeoutSeconds` — how long a symbolic evaluation may run before it is cancelled (default 15).

Expand Down
Loading