Sagebrush · Blog · Articles · Performance

Sagebrush and Pyodide, measured

Written by Claude Opus 5.5, an AI model made by Anthropic, from measurements of the Sagebrush project, led by William Stein (SageMath, Inc.).

Measured on Oct 18, 2026: headless Chrome 155 on a quiet Linux VM (48 cores of an AMD EPYC 7B13; one-minute load average at most 1.1 throughout). Sagebrush 0.5.0 at commit 8d3a5295 (build 4e24e8e68b5d5ada); Pyodide 314.0.7 (CPython 3.14.2). Five cold starts per engine. The tables give the median, with the lowest and highest of the five in brackets.

Sagebrush runs Python in the browser without CPython. Its own compiler turns Python into JavaScript, which the browser's JIT runs, alongside a library written for it: numpy, a subset of scipy, and the Sage, MATLAB and Magma modes. Pyodide is CPython itself, compiled to WebAssembly, with real NumPy and much of the scientific stack built the same way.

They make different trade-offs. This page measures both the same way, with a script anyone can run (web/bench-compare.mjs in the repository).

In the browser, Sagebrush is small and starts fast. A cold start transfers 0.38 MB against Pyodide's 6.04 MB and prints its first result 155 ms after navigation, against 2,008 ms. import numpy then takes 149 ms against 886 ms. Running speed depends on the workload; the tables below include rows chosen because Sagebrush's design should be weakest there, and how much memory each engine holds over a session.

What Sagebrush does not claim. It does not run every Python program the way CPython does:

Operations it does not support are intended to raise an error rather than return a guess. The workloads below are ones both engines run the same way. Every execution of each one, in every cold start of both engines, had to print the same result, or the measurement would have failed.

How it was measured

These are not full notebook visits. Each engine runs in a minimal page that starts its interpreter and nothing else: Sagebrush's notebook worker without the notebook around it, and Pyodide on the page's main thread, following its quickstart.

Downloading and starting

Each cold start loads the interpreter and runs print(1 + 1).

Sagebrush Pyodide 314.0.7
transferred / uncompressed 0.38 / 1.46 MB 6.04 / 13.5 MB
interpreter ready 107 ms (104–108) 1,945 ms (1,931–1,991)
first print(1 + 1) result, from navigation 155 ms (153–206) 2,008 ms (1,974–2,045)
import numpy: transferred / uncompressed 0.34 / 2.05 MB 2.96 / 2.96 MB
import numpy: time 149 ms (145–152) 886 ms (881–904)

Running

Each workload runs once to warm up, then five times in the same session. For each cold start the script takes the median of the five timed runs, timed inside the page. The table gives the median of those over the five cold starts, and their range. Between workloads the script forces a garbage collection and reads the memory (see Memory, below).

The two multiplication rows time one product, c = a * b, and print its bit length and its remainder modulo 1,000,003. Before the warm-up, an untimed setup step builds the operands, two integers of about (or ) decimal digits, from hex strings. That setup step's output is checked as well.

workload Sagebrush Pyodide
the sum of 3,000,000 squares, in a loop 172 ms (172–182) 731 ms (669–795)
recursion, fib(25) 6 ms (6–6) 18 ms (17–20)
a dict of 200,000 string keys, sorted 80 ms (78–81) 91 ms (87–100)
big integers, factorial(20000) 5 ms (5–5) 11 ms (11–12)
big integers, one multiplication of two -digit numbers 34 ms (34–34) 709 ms (707–718)
big integers, one multiplication of two -digit numbers 381 ms (377–381) 28,098 ms (28,027–28,126)
a byte sieve to 2,000,000 17 ms (16–17) 29 ms (26–30)
JSON, 30,000 small objects there and back 143 ms (140–147) 142 ms (141–149)
numpy, a 300×300 matrix product 13 ms (12–13) 29 ms (29–30)
numpy, elementwise on 1,000,000 floats 540 ms (537–549) 13 ms (13–13)

These explanations are architectural context for these workloads, not separate measurements:

Where Sagebrush's design is weakest

These rows were chosen because they work against compiling Python to JavaScript.

workload Sagebrush Pyodide
2,000 distinct small functions, each built with exec() and called once 417 ms (402–424) 128 ms (127–130)
one call site over objects of 50 classes with different layouts 116 ms (114–118) 72 ms (71–74)
the same loop over objects of one class (the control) 13 ms (13–13) 50 ms (50–53)

Memory

The two engines manage memory in different ways, and it shows over a session.

How it was measured. The numbers are the private memory (USS, pages no other process shares) of the page's renderer process. That process holds the page, Sagebrush's worker, both JavaScript heaps and Pyodide's WebAssembly memory. The browser's other processes hold about the same for both engines and are not counted.

the page's renderer, private memory (MB) Sagebrush Pyodide [its WebAssembly memory]
after print(1 + 1) 27 (27–28) 79 (78–79) [31]
after import numpy 38 (38–39) 116 (116–116) [45]
one multiplication of two -digit numbers: peak 394 (393–394) 194 (193–194)
the same, after a collection 78 (77–78) 195 (194–195) [136]
JSON, 30,000 small objects: peak 180 (179–181) 195 (195–196)
the same, after a collection 113 (113–113) 195 (195–196) [136]
numpy elementwise: peak 161 (159–161) 221 (221–221)
the same, after a collection 124 (124–125) 221 (220–221) [163]
after the last workload, then 30 s idle 141 (140–142) 220 (220–220) [163]
every global deleted, gc.collect(), a collection 76 (76–77) 220 (220–220) [163]

How to reproduce

node scripts/build-cli.mjs
bun web/build.ts
node web/bench-compare.mjs --pyodide DIR --runs 5 --json out.json

DIR holds Pyodide's distribution (pyodide.mjs, pyodide.asm.wasm, python_stdlib.zip, pyodide-lock.json) and the numpy wheel. The script exits with an error if any execution printed something different, and node web/bench-compare.mjs --check FILE.json checks a saved run again. The memory measurements need Linux, since they read /proc. The raw data of the run above, with every cold start's and every timed run's time and output, every memory reading, and each session's memory timeline, is articles/performance/data/sagebrush-pyodide-2026-10-18.json. The previous run, before the multiplication rows, the product trees and Sagebrush's _json, is sagebrush-pyodide-2026-10-17.json.

Updated 2026-10-18 · source on GitHub