IDE, frameworks, versions, ORM, etc.  a survey by the Python Software Foundation and JetBrains

PyScript, the framework for creating advanced Python applications in the browser, allows you to embed Python and HTML

At a keynote conference at PyCon 2022 Salt Lake City, Utah, Peter Wang, president and CEO of Anaconda, Inc., introduced another newcomer to Python interpreters in browsers. The Python community has long been looking for a way to write Python, rather than JavaScript, to run in web browsers, and there have been several efforts in this direction over the years. Wang announced PyScript as a new framework, based on one of these previous projects, to allow Python to be written directly to the browser.

These programs have access to much of the existing Python ecosystem and can interact directly with the document object model (DOM) of the browser. In addition, he made quite revealing demonstrations as part of his presentation.

Wang began by introducing himself and the company he runs, Anaconda, which he co-founded with Travis Oliphant ten years ago. Oliphant is the creator of NumPy and one of the founders of SciPy, both of which are cornerstones of Python’s scientific computing ecosystem. Anaconda is a distribution of Python and R programming languages ​​for scientific computing (data science, machine learning applications, large-scale data processing, predictive analytics, etc.), which aims to simplify management and the deployment of packages.

The distribution includes data science packages suitable for Windows, Linux and macOS. It is developed and maintained by Anaconda, Inc., which was founded by Peter Wang and Travis Oliphant in 2012. As a product of Anaconda Inc., it is also known as Anaconda Distribution or Anaconda Individual Edition, while other products of Anaconda the company are Anaconda Team Edition and Anaconda Enterprise Edition, both paid.

There are several reasons why Anaconda and Oliphant focus their efforts on Python, including the fact that this language is accessible even to those who do not have a computer background. Another point in their favor is that the Python community is generally welcoming and fun to work with. This is a very important point if we want to continue to expand the user base.

Anaconda has created a number of different tools that are widely used in the community and also founded the non-profit conferences NumFOCUS and PyData.

But there is another aspect of the language that makes it so desirable from his point of view: it can be expanded with binary extensions that use an API written in C, but accessible from other languages. Wang compares Python to a Honda Civic with mounting screws for a warp engine. That way, kids can learn the language and then they can open the trunk and stick them to the warp pods that allow the code to run faster than C or C ++ in some cases, Wang said.

This aspect is sometimes overlooked, but it means that Python can be used in a way that other similar languages ​​do not. It’s not just like Node, it’s not just an alternative to Ruby. The reason Python was taken over by Wall Street companies 10 or 15 years ago was this deformation capability, he said.

What is missing

While it is true that Anaconda intends to offer a Python distribution, it is no less true that installing everything you need for Python is too difficult. There are a large number of packages in the Python Package Index (PyPI), but it is difficult to make them work together. 20% of Python programmers have a bad experience with language. There are many different tools to help with this problem, but they are all around 80%, he said, that is, people have a bad experience 20% of the time, which doesn’t matter, it’s “not great”.

It is strange that for the most popular language in the world, such as Python, it is difficult to write and distribute applications with a user interface. For example, you can’t write iOS apps with Python. You can’t create an application for Windows, the most popular enterprise desktop, with a user interface; Even if you use a web front-end, you have to write JavaScript, CSS, and HTML, Wang said.

However, the consequences of these two points, i.e. the difficulties associated with compiling and creating user interfaces, make it difficult to share your work with others. To those who see Docker as a solution to this problem, Wang responds that when you make an app with Docker, you pack a hard drive and send it to someone. This cannot be our way of getting millions of people to use this material.

To a large extent, Python is a victim of its own success. It’s a great linking language, but that means linking all these things. Much of what we do in computer science is tied to the ideas and architectures of the 70s and 80s, he said, starting with the C language and the Unix process model; it also includes things like tool chains and interconnection protocols like TCP / IP. The basics of the Python language itself can be taught to anyone in a weekend, he said, but it takes a lot more effort to get to the point where they can create an executable for Windows or an iOS app for an iPad. Can we free Python from all this?

Python and WebAssembly

The web browser has clearly won the war of the operating system, Wang said. He doesn’t know if 2022 will be the year of the Linux desktop, (he won’t), but he knows there will be a lot of browsers on desktops. JavaScript is the king of some linguistic popularity polls, as it is the native language of the browser. So if we want to get into that area, he said, WebAssembly (or Wasm) is clearly the right answer.

WebAssembly is a fundamental game changer. This is a set of virtual CPU instructions that recently became a W3C standard; it has a 32-bit address space and can perform 64-bit arithmetic operations. There is a compilation tool, Emscripten, that can be used to compile most of the C and C ++ code in WebAssembly, which can then be run in the browser. According to Wang, WebAssembly is well compatible with browsers, including mobile browsers.

CPython is, of course, a C program, and much of Python’s digital stack is written in C or C ++. In recent years, projects such as and JupyterLite have compiled large parts of Python’s scientific and numerical stack to guide WebAssembly.

By going to the Pyodide site, it is possible to get a Python read-evaluate-print (REPL) loop in your browser. From these three nice little corner brackets, it is possible to import NumPy and pandas. From the JupyterLite site, it is possible to get a notebook in the browser by running JupyterLab on the local system.

Christian Heimes, lead developer of Python, has given talks and done a lot of work to make CPython work with WebAssembly. It will soon be a level 2 compatible platform for CPython, Wang said. WebAssembly simply provides another computing architecture, beyond x86, Arm and others, that the CPython project can target.


Wang and other members of Anaconda reviewed the work done and thought of ways to make it more accessible to many more people. To that end, Wang announced PyScript, but did so by encoding a live “hello world” demo from the conference stage. It was his first PyCon lecture, maybe my last, ”he said laughing, as he wrote a short HTML file that loaded a pyscript.js pyscript.js file into a tag.


   print("Hello PyCon 2022!")

He then double-clicked the file and the greeting appeared on a browser tab; which was greeted with applause. But it’s all HTML, he said, so he wrapped the previous code in a tag and reloaded. These days, of course, the tag has been removed from HTML, perhaps unfortunately; now I have to explain to the children that there is no lighthouse.

So he added a blink functionality to the PyScript code and proved a few more things. He created a

with a name, which he then directed to write the string by accessing the DOM to retrieve the object for the

; also used the asyncium module to run out of time for a second, then removed the

and put everything in a loop.

Therefore, PyScript is a framework for creating rich Python applications in the browser. It allows embedding Python and HTML, provides full access to the DOM, and gives code access to JavaScript libraries, in both directions. Python code can call JavaScript or be called JavaScript. Thus, all the logic and code of the application can be in one language, in the browser, without the need for a web server. It is possible to put the HTML file on a USB stick and give it to a friend. You need to download PyScript itself, but this is done from the HTML file using the file.

PyScript is not a kind of bifurcation of CPython, it is the same code that participants ran on their laptops and servers, said Wang, who had just compiled it for Wasm. It includes all the work that Pyodide has done to make the major digital, scientific, and big data packages work for Wasm as well. PyScript is an opinion framework that provides a foreign function interface (FFI) for speaking with JavaScript and the DOM; Python has already integrated C, C ++ and Fortran, so JavaScript can also be added to the list. It really is a serverless computer.

Source: LWN

And you?

What is your opinion on PyScript?

Do you think PyScript can be as good as JavaScript for running in a web browser?

See also:

Version 3.2 of the Django framework is available, with automatic discovery of AppConfig, brings new decorators for the administration module

Python 3.11 will improve the location of bugs in layouts and bring new features

Python 3.11 will gain performance at the expense of a little more memory, speed gains seem to be between 10% and 60%

Linux kernel version 5.17 is available, provides very important security solutions and a significant improvement to the random number generator

Version 1.15 of the Go programming language will be released soon, with improvements in tools, compiler performance, and the standard library.

Leave a Comment

Your email address will not be published.