Release of Brython 3.11, an implementation of the Python language for web browsers

The release of the Brython 3.11 project (Browser Python) has been presented with an implementation of the Python 3 programming language for execution on the client side in web browsers, allowing the use of Python instead of JavaScript for Web script development. The project's code is written in Python and is distributed under the BSD license.

By connecting the brython.js and brython_stdlib.js libraries, web developers can use Python to define site logic on the client side, applying Python instead of JavaScript. To include Python code on pages, the <script> tag with a mime type of 'text/python' is used. Both embedding code directly on the page and loading external scripts (<script type="text/python" src="test.py">) are allowed. Full access to DOM elements and events is provided from the script. In addition to access to the Python standard library, specialized libraries are offered for interaction with the DOM and JavaScript libraries such as jQuery, D3, Highcharts, and Raphael. CSS frameworks Bootstrap3, LESS, and SASS are supported.

Executing Python code from blocks <script> производится через предварительную компиляцию этого кода, выполняемую обработчиком Brython после загрузки страницы. Компиляция инициируется при помощи вызова функции brython(), например через добавление «<body onload="»brython()»">». На основе Python-кода формируется представление на языке JavaScript, которое затем выполняется штатным JavaScript-движком браузера (для сравнения, проект PyPy.js предлагает для выполнения Python-кода в браузере скомпилированный в asm.js интерпретатор CPython, а Skulpt реализует интерпретатор на JavaScript).

The overall performance of most operations in embedded Python scripts for web pages is close to that of CPython. There is a delay only at the compilation stage, but to eliminate this, there is the option to load pre-compiled JavaScript code, which is used to accelerate the loading of the standard library (Brython provides a toolkit for creating JavaScript libraries based on Python modules).

This new release is notable for ensuring compatibility with CPython 3.11 and implementing most of the new features of this branch, including support for exception groups and the 'except*' expression, improved expression detail in diagnostic messages, and attaching notes to exceptions.

Source: opennet.ru

Buy reliable website hosting with DDoS protection, VPS VDS servers 🔥 Buy reliable website hosting with DDoS protection, VPS VDS servers | ProHoster