I'm very excited to see that it is now possible to code Python in the browser. These are the main candidates (please add any I may have overlooked):
But how to choose between them? The only obvious difference I can see is that Skulpt is based on Python 2, whereas Brython is based on Python 3.
Please note: This is not a request for recommendations or opinions. I'm seeking objective facts that would inform an educated choice.
First of all I'm a Brython committer . Nevertheless I'll try to be as impartial as possible for the sake of doing an objective assessment .
The last time I used it Skulpt did not support features like generator expressions . Brython and PyPy.js do so , so at the feature level IMHO the later are superior .
Brython (at this time) is still work in progress . Some modules cannot be imported (e.g. xml.ElementTree ) . Nevertheless this situation is starting to change since we are working towards running the whole CPython test suite in spite of achieving full compatibility with standards (at least when it makes sense) .
Brython also supports .vfs.js to speed up module imports .
PyPy.js has a number of characteristics that follow straightforward from the fact of it being powered by PyPy (JIT compilation , well tested , ...) but I'm not sure of whether it is suitable for running in the browser . This might change as the project evolves .
TODO: I'll try to complement my answer with reliable benchmarks .
Not mentioned here is RapydScript or RapydScript-NG. They produce very efficient JavaScript code, which is used in GlowScript VPython (glowscript.org). I used to use the original RapydScript of Alex Tsepkov (https://github.com/atsepkov/RapydScript) but recently switched to RapydScript-NG of Kovid Goyal (https://github.com/kovidgoyal/rapydscript-ng). I recently ran the pystone benchmark on CPython, RapydScript, and Brython, and you can see the results here:
https://groups.google.com/forum/?fromgroups&hl=en#!topic/brython/20hAC9L3ayE
This might be helpful too: http://stromberg.dnsalias.org/~strombrg/pybrowser/python-browser.html
It compares several Python-in-the-browser technologies.
This is an updated conference which compares all available options in the market right now:
https://www.youtube.com/watch?v=2XSeNQyPlTY
The speaker is Russell Keith-Magee, who is a well known developer in the area.
I've used and committed to skulpt as well as pypyjs. And they are all three very different that any comparison is moot if you ask me.
It depends on what you are looking for which will make the most sense.
PyPyJS
pypyjs is huge it's a 12MB javascript file that contains the entire pypy virtual machine. So if you want python implementation completeness this is your baby. It has a javascript bridge that works really good but it's not a viable option for writing your javascript website code in python. It will however let you
import compiler
.It's built with emscripten and is faster then CPython, in running the pystone benchmark.
I gave a short talk about pypyjs here are the slides.
Skulpt
Is a teaching tool (or it has evolved into that over time), it compiles your python into a state machine very closely emulating the cpython compiler. At it's core it's a handwritten implementation of the python compiler in javascript. It allows for asynchronous execution which lets you do:
Without locking up the browser.
Skulpt is the only one that supports asynchronous continuations, it lets you pause the execution of python while it's resolving some asynchronous thing to happen. Making this work:
Skulpt runs at about a tenth of the speed of CPython, when comparing pystone.
Brython
I know least about this one maybe @olemis-lang can expand this one. But next to the obvious difference that Brython is py3 and the others py2. Brython is also a transpiler.
Brython doesn't run the pystone benchmark because time.clock isn't implemented, because officially it's a hardware function.
Since nobody has mentioned it I thought it was worth it to mention Batavia which implements the Python virtual machine for running precompiled Python bytecode.
I just tried it and, while it's an interesting concept, it is still in early stages as there is little documentation.
In the end it will depend on what you are trying to do. I chose Transcrypt after having a look because it was more pragmatic and better performant, also more recently released/maintained.