Different Python flavors

In the Numba section, we showed you how to use Numba to speed Python code up. To do so, Numba uses a modern compilation engine. It does so by exploiting the C nature of Python. Another project, Cython, does the same—it compiles Python code into C using a somewhat different approach.

A third (or, chronologically, the first) option is PYPY (not to be confused with PYPI)a totally separate interpreter for the Python language. Compared to Numba and Cython, PYPY does not need any changes to be made in the code itselfall the optimization is done under the hood in the interpreter. While this is convenient, the problem is that PYPY requires some work since it needs a proper installation of Numpa, sklearn, and basically any other beyond-simple-Python package, so it is rarely used on data-heavy applications.

But there is a whole slew of other options as well! For example, Jython (as you can guess from the name) is a Java-based Python interpreter, which can come in handy if you want to integrate your Python code as part of broader Java code or applications. Another, known as Brython, is a JavaScript-based interpreter that you can use to write both the backend and frontend of your website in Python. In fact, there is a package called vue.py (https://stefanhoelzl.github.io/vue.py/), based on the Brython and Vue frontend framework, that attempts to cover both backend and frontend web development at the same time. Of course, we should note that while Numba and Cython try to make Python faster, Brython's goal is to run JavaScript via a Python interface. Due to this, performance is a lot slower.

Something that sits aside from other projects is the PyIodide project. It does not mimic Python in any other language. Instead, it compiles it into WebAssembly formata special type of binary format that can be executed in a browser, and so anywhere you can open a browser—whether it be a mobile phone, a tablet, or a smart fridge. It can also interact with web pages similar to JavaScript, on any major browser! While being somewhat slower, this approach works and is very promising.

As an example, Pyodide offers a notebook-style application to try out (https://github.com/iodide-project/pyodide)it almost looks like Jupyterexcept that this time, there is no Python servereverything (for example, matplotlib, sklearn, and so on) runs on your machine. Here's what it looks like:

Similarly, the PyIodide package can run other languagesRust, Go, and moreall in a browser, with no installation required. For more information on PyIodide, check out this video by Michael Droettboom for PyData New York, 2018: https://www.youtube.com/watch?v=iUqVgykaF-k.

Another far-fetched but very interesting application for PyIodide (and WebAssembly in general) is as a lingua franca for packaging so that you don't need to worry about adding dependencies, Python, and so on—just download the file and run it. But this is all perspective—for now, we have Docker containers to do that.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
18.223.168.28