The release of Brython 3.14.1 (Browser Python) is available, implementing the Python 3 programming language for 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).
The new release is noted for a complete redesign of the implementation of built-in types and a rewrite of the code for parsing arguments of built-in functions and methods. In the Brython 3.14 branch, compatibility with CPython 3.14 is ensured and most of the new features of this release are implemented, including support for f-strings and deferred annotation processing.
Source: opennet.ru
