![]() |
BrythonA Python 3 implementation for client-side web programming |
Brython is designed to replace Javascript as the scripting language for the Web. As such, it is a Python 3 implementation, adapted to the HTML5 environment, that is to say with an interface to the DOM objects and events.
Brython is not "Python-like", but tries to be as close as possible to the Python language ; in other words, the features that work in CPython but not Brython are considered bugs. The only limitations are the features that can't be implemented in Javascript (eg. blocking funcions) or those related to the browser environment (eg. or writing to disk). But it is close enough to Python 3 to support online courses such as Carnegie Mellon University's Computer Science Academy. Despite this stress on compliance, execution time is sometimes faster, sometimes slower, rarely much slower than CPython. With Firefox, the table below shows how Brython performs compared to CPython (taking 100 as base for CPython)
The modules in the standard library are translated only once for each new Brython version ; they are then stored in an indexedDB database on the client side. The first run of a program that uses many stdlib modules might take a few seconds, but the next runs will be much faster. The size of the core Brython script is 134 kB once minified and compressed. The standard library can be loaded as a single script, its size is 699 kB. All popular Javascript frameworks (jQuery, vue.js, Highcharts, etc.) can be easily used from inside Brython scripts. You can take a look at applications developed with Brython, and watch videos and talks. Documentation and online resources are available on this site. The development site is on Github. Contributors are welcome ! |
BrythonUne implémentation de Python 3 pour la programmation web côté client |
L'objectif de Brython est de remplacer Javascript comme langage de script côté client. Il s'agit d'une implémentation de Python3, adaptée à l'environnement HTML5, avec une interface vers les objets et les événements DOM.
Brython n'est pas "ressemblant à Python", mais essaie d'être aussi proche que possible du langage Python. En d'autres termes, tout ce qui fonctionne en CPython mais pas en Brython est considéré comme un bug. La seule limite sont les fonctionnalités qui ne peuvent pas être implémentées en Javascript (par exemple les fonctions bloquantes) ou celle qui sont liées à l'environnement sécurisé du navigateur (écriture sur disque par exemple). Mais il est suffisamment proche de Python 3 pour servir de support à des cours de programmation en ligne comme celui de la Carnegie Mellon University's Computer Science Academy. Malgré cet accent mis sur la conformité, les temps d'exécution sont parfois plus rapides, parfois plus lents, rarement beaucoup plus lents qu'en CPython. Avec Firefox, la table ci-dessous montre les performances sur un certain nombre d'opérations élémentaires, en prenant CPython comme base 100:
Les modules de la librairie standard sont traduits une seule fois pour chaque nouvelle version de Brython; elles sont ensuite cachées dans une base de données indexedDB côté client. La première exécution d'un programme qui utilise beaucoup de modules de la librairie standard peut prendre plusieurs secondes, mais les exécutions suivantes seront beaucoup plus rapides. La taille du script principal de Brython est de 134 kO une fois minifié et compressé. La librairie standard peut être chargée comme un seul fichier, sa taille est de 699 kO. Tous les frameworks Javascript (jQuery, vue.js, Highcharts, etc.) peuvent être utilisés simplement depuis les scripts Brython. Pour vous faire une idée, vous pouvez utiliser la console interactive, regarder quelques applications développées en Brython, and voir des vidéos et des conférences. La documentation et des ressources sont disponibles sur ce site. Le site de développement est sur Github. Les contributeurs sont bienvenus ! |
BrythonUna implementación de Python para la programación web del lado del cliente |
Brython is designed to replace Javascript as the scripting language for the Web. As such, it is a Python 3 implementation, adapted to the HTML5 environment, that is to say with an interface to the DOM objects and events.
Brython is not "Python-like", but tries to be as close as possible to the Python language ; in other words, the features that work in CPython but not Brython are considered bugs. The only limitations are the features that can't be implemented in Javascript (eg. blocking funcions) or those related to the browser environment (eg. or writing to disk). But it is close enough to Python 3 to support online courses such as Carnegie Mellon University's Computer Science Academy. Despite this stress on compliance, execution time is sometimes faster, sometimes slower, rarely much slower than CPython. With Firefox, the table below shows how Brython performs compared to CPython (taking 100 as base for CPython)
The modules in the standard library are translated only once for each new Brython version ; they are then stored in an indexedDB database on the client side. The first run of a program that uses many stdlib modules might take a few seconds, but the next runs will be much faster. The size of the core Brython script is 134 kB once minified and compressed. The standard library can be loaded as a single script, its size is 699 kB. All popular Javascript frameworks (jQuery, vue.js, Highcharts, etc.) can be easily used from inside Brython scripts. For more information, you can use the interactive console, take a look at applications developed with Brython, and watch videos and talks. Documentation and online resources are available on this site. The development site is on Github. Contributors are welcome ! |