CPython to LLVM to Javascript - Python in the browser
syntensity.com
syntensity.com
http://syntensity.com/static/python.js
Also geeky fun to try to recognize what constants like 4294967295 correspond to -- it's all over the place!
And lots of literal char* strings encoded as integer sequences:
>>> s = [111,98,106,101,99,116,46,95,95,102,111,114,109,97,116,95,95,32,119,105,116,104,32,97,32,110,111,110,45,101,109,112,116,121,32,102,111,114,109,97,116,32,115,116,114,105,110,103,32,105,115,32,100,101,112,114,101,99,97,116,101,100,0]
>>> ''.join(map(chr,s))
'object.__format__ with a non-empty format string is deprecated\x00'Oh wait! pyjamas does exactly that http://pyjs.org/ This is the first time I came to know about this project. So I have no experience with it whatsoever. [Well, that applies to my experience with javascript too.]
Edit: from a quick look it seems pyjamas will not give you a python REPL, I am not sure. But nevertheless this looks very interesting
Well no, this is not possible, because python and javascript have very different semantics, notably regarding numeric types. You would have to enclose every python numeral in an object, and that in itself would already cripple the performance quite a bit. It would probably be less than the emscripten approach, but not by that much of a margin.
I started doing a python to lua compiler, and did hit that wall very fast.
Pyjamas python to javascript compiler is basically a toy regarding compliance to python spec. Every number is treated as a float, which means any numeric python library/function may not work correctly in pyjamas.
That's not the only difference in semantics between python and javascript. Just the most performance expensive.
I can select the section of code but not actually edit it. It's just plain, unadorned text in a regular div.
But pressing Execute does nothing anyway, apart from a page refresh.
Long answer, it can run some parts of it if you join them (e.g., separating tokens, counting probabilities, some tagging and even some more advanced stuff). You cannot however, run everything (for exemple, modules and functions depending on NumPy) and must deal with how to import/export data.