{
  "id": 8698808,
  "title": "The last mile of a long road: faster NumPy in the browser",
  "url": "https://urgent.news/2026/09/20/the-last-mile-of-a-long-road-faster-numpy-in-the-browser",
  "topic": "tech",
  "section": "Tech",
  "published": "2026-09-20T09:07:28.000Z",
  "source": {
    "name": "Lobsters",
    "slug": "lobsters",
    "url": "https://notebook.link/blog/the-last-mile-faster-numpy"
  },
  "original_language": "en",
  "account": "For many years, executing NumPy in a web browser required running it without accelerated BLAS (Basic Linear Algebra Subprograms). Matrix multiplications relied on straightforward loops, which were portable but inefficient due to their lack of optimization for cache and SIMD (Single Instruction Multiple Data). This all changed with the introduction of the Emscripten-forge NumPy package, which now links OpenBLAS in WebAssembly. When provided with a matrix size of 1024, np.matmul (a matrix multiplication function in NumPy) experienced a significant speed increase, becoming approximately 30.92 times faster for float32 and 14.90 times faster for float64. The next OpenBLAS release, already available as an experimental package on Emscripten-forge, further improved performance, and an optional Relaxed SIMD build provides yet another enhancement. Emscripten-forge is a software distribution for WebAssembly, working in conjunction with conda-forge to rebuild the conda ecosystem for WebAssembly. This allows compilers, runtimes, and shared libraries to be packaged as redistributable conda packages with a coherent Application Binary Interface (ABI), similar to native libraries that can be linked by any language ecosystem. Bringing scientific languages to the browser has been a challenging task, often requiring a language-specific distribution. Pyodide pioneered this approach for Python, followed by WebR for R. Emscripten-forge takes a different approach, serving as a language-agnostic distribution that builds upon the foundational work of Pyodide and WebR, and covers a wider range of tools, including C++, OCaml, Lua, compiler toolchains, and more. Fortran, a crucial component of foundational scientific packages like LAPACK, SciPy, and R's compiled statistical routines, requires a Fortran compiler that can target WebAssembly. For a while, Pyodide worked around this limitation by using f2c, a Fortran-to-C translator, to produce SciPy builds in the browser. However, this workaround was insufficient for R, necessitating the development of a Fortran toolchain for WebAssembly. The effort to build a Fortran toolchain for WebAssembly involved contributions from Isabel Paredes and Serge Guelton, who initially wrote the necessary patches for Flang (LLVM's Fortran frontend) for WebAssembly. These patches were further upstreamed into LLVM by Serge Guelton. Once a working Flang toolchain was in place, additional patches were required to adapt OpenBLAS for Flang and Emscripten, enabling the compilation, archiving, and linking of the library under Emscripten. Ian Thomas played a key role in adapting OpenBLAS for Flang and Emscripten, with the relevant patches integrated into the Emscripten-forge OpenBLAS recipe. The last step in making NumPy faster in the browser was linking it to an accelerated BLAS. The previous Emscripten-forge NumPy package (version 2.5.2) did not include OpenBLAS, resulting in slower matrix multiplication operations that relied on portable C loops. With the default NumPy on Emscripten-forge-4x now linking OpenBLAS 0.3.34 (with WASM SIMD support), matrix products exhibit significant speed improvements, reaching about 30.92 times faster for float32 and 14.90 times faster for float64.",
  "summary": null,
  "key_points": [],
  "editors_take": null,
  "illustration": null,
  "coverage": {
    "outlets": 1,
    "also_reported_by": []
  },
  "ai_generated": true,
  "disclaimer": "Summaries, key points and the editor’s take are written by software from other outlets’ reporting and may contain errors — always check the linked original."
}