Mozilla’s Pyodide Project Brings Python To The Web Browsers

Mozilla seems to be quite active these days. Not only for the Firefox browser, but the non-profit organization is working on some interesting products and future-oriented technology. After the announcement of Firefox Send and Lockbox, now the company is bringing one of the biggest updates for web browsers.

Mozilla’s Pyodide Project Brings Python Data Science to Browsers

Mozilla Firefox

According to a recent report by VentureBeat, Mozilla’s experimental Pyodide project is bringing Python data science stack to the web browser by compiling it to WebAssembly. Similar to Mozilla’s Iodide project, developers can use Pyodide as standalone or with context to run python in a browser.

If you are unaware, Pyodide is an implementation of Python’s Numpy scientific computing library, Pandas data analysis library, some parts of the SciPy library for math, science, and engineering. There’s also some contribution of Python’s Matplotib plotting library as well.

It provides transparent conversion of objects between Javascript and Python. When inside a browser, this means Python has full access to the Web APIs. Basic data types are implicitly converted and JavaScript typed arrays are converted to Python memoryviews.

JavaScript is the reason behind Pyodide. It’s already known as the language of the browser but does not have many features of data science libraries. Numerical computing features such as operator overloading are also missing as well. Mozilla may want to see the JavaScript data science ecosystem succeed, but bringing a complete Python scientific stack to the browser is definitely useful.

Pyodide compiles the standard Python interpreter, CPython, NumPy to WebAssembly binary format using Emscripten, and runs alongside the JavaScript in the browser. If you want to load the Pyodide into the browser, it will require the following things:

  • Compiled Python interpreter as WebAssembly
  • JavaScript from Emscripten that emulate system capabilities such as a virtual file system like a one expected by the Python interpreter
  • Python interpreter supportive files including the Python standard library

As the files can be large, you have to only download the packages only once and they will be stored in the browser cache. You can try Pyodide by running a demo notebook from the Iodide website. If you are interested in building Pyodide, instructions are given on the Github.

Also Read: 10 Best Python Courses For Programmers and Developers

Talking about other products, Mozilla keeps updating its Firefox browser to cope with the latest user tracking methods. The company is currently working to add Tor’s Anti-Fingerprinting technique dubbed as ‘Letterboxing’ in Firefox 67. The updated is expected to be released in May 2018.

Leave a Comment

This site uses Akismet to reduce spam. Learn how your comment data is processed.