← back to index

Wasthon — array throughput

Note: Brython's pure-Python Lib/array.py rejects valid typecodes and is missing methods like append; we compare against Brython's list instead (the workaround Brython users currently rely on). Wasthon adds a real, typed array to the browser-Python ecosystem.

Why extend shows a loss (~0.02×): the test feeds a Python iterable of 10000 ints into array.extend, which crosses the JS↔WASM bridge once per element — exactly the work-density anti-pattern. Brython's list.extend stays JS-side. The two win cases below (tobytes, tobytes+frombytes) batch the work in a single bridge crossing and recover an order of magnitude. The point of array isn't to extend faster, it's to expose a contiguous byte view of typed data; the tobytes rows are what matters.

Operationwasthon arrayBrython list Speedup

Log