Pyodide: Mozilla Brings Python to the Browser

DZone 's Guide to

Pyodide: Mozilla Brings Python to the Browser

This is Mozilla's effort to introduce the Python data science stack to the web browser.

· Big Data Zone ·
Free Resource

Image title

Screenshot of Pyodide's demo notebook

Mozilla introduced Pyodide last week, an open source experiment designed to create a full Python data science stack that runs out of the web browser.

Pyodide stems from Iodide, another early-stage Mozilla project, that performs data analysis without needing a remote kernel.

"Unfortunately, the 'language we all have' in the browser, JavaScript, doesn't have a mature suite of data science libraries, and it's missing a number of features that are useful for numerical computing, such as operator overloading," Mozilla data engineer Michael Droettboom wrote in a blog post. "We still think it's worthwhile to work on changing that and moving the JavaScript data science ecosystem forward. In the meantime, we're also taking a shortcut: we're meeting data scientists where they are by bringing the popular and mature Python scientific stack to the browser."

"While Pyodide isn’t exactly novel — projects like Transcrypt, Brython, Skulpt, and PyPyJs are among several efforts to bring Python to browsers — it doesn’t require a rewrite of popular scientific computing tools (like NumPy, Pandas, Scipy, and Matplotlib) to achieve adequate performance," VentureBeat reported last Tuesday. "Its ability to convert built-in data types enables interactions among browser APIs and other JavaScript libraries."

Pyodide uses WebAssembly to interact with JavaScript already running in the browser. Rather than simply converting JavaScript commands into Python, Pyodide creates proxies that keep the original variable and refer back to it on demand. All JavaScript variables, even custom ones, can be called directly from Python. 

In a keynote speech at PyCon 2018, Dan Callahan argued that Python's inability to work on the web posed a threat to its survival as a programming language. Pyodide's creators had this warning in mind.

"With so much user interaction happening on the web or on mobile devices, [Python] needs to work there or be left behind," Droetboom wrote. "Therefore, while Pyodide tries to meet the needs of Iodide first, it is engineered to be useful on its own as well." Pyodide's documentation includes a section on how to use it directly from JavaScript as well as from Iodide.

If you'd like to try out Pyodide for yourself, you can go here and experiment with some higher-level features in a demo notebook (50MB download).

big data, mozilla, news, pyodide, python, python data science

Opinions expressed by DZone contributors are their own.

{{ parent.title || parent.header.title}}

{{ parent.tldr }}

{{ parent.urlSource.name }}