Skip to content

Comment on A possible future of Python in the browser

Comments

Python is a fine language. It has a nice enough JIT compiler by now. Its structure is similar enough to JS to allow easy interop, and easy exposure of browser APIs exactly the way these APIs are exposed to JS.

But the power of Python currently mostly lies in its being a glue language. Python easily and neatly wraps things like numpy, scipy, polars, pytorch, etc, all implemented in native code. Not being able to use these would be a major limitation. But being able to use these would be a colossal change to the browsers' capabilities, security model, and, well, purpose.

The article mentions use of Numpy on web.

Pyodide has numpy, scipy, matplotlib, pandas, and as of last month, even polars. https://github.com/pyodide/pyodide/pull/5282

Pyodide is far from a perfect CPython and even the packages it includes often have limitations you won't find when running natively. But there's definitely enough here to be interesting and even somewhat useful. Here's an interactive app written on Pyodide that uses astropy, numpy, and matplotlib: https://shinylive.io/py/examples/#orbit-simulation

AboutSource Built by g1lg1l

Hackerly is an independent reader for Hacker News, built on the public HN API. Not affiliated with Y Combinator.