CPython on the Web

azakai alonmozilla at gmail.com
Sun Jan 2 02:26:50 EST 2011


Hello, I hope this will be interesting to people here: CPython running
on the web,

http://syntensity.com/static/python.html

That isn't a new implementation of Python, but rather CPython 2.7.1,
compiled from C to JavaScript using Emscripten and LLVM. For more
details on the conversion process, see http://emscripten.org

This is a work in progress, main issues right now are that the code
isn't optimized (so don't expect good performance), and importing non-
static modules doesn't work. Otherwise, though, it seems to run
properly, in particular it runs all the examples in
http://wiki.python.org/moin/SimplePrograms that don't rely on
importing modules or receiving input from the user (with perhaps some
minor formatting errors). The demo runs fine on recent versions of
Firefox, Chrome and Safari, but has problems on IE9 and Opera
(hopefully those will be resolved soon).

The idea is that by compiling CPython itself, all the features of the
language are immediately present, and at the latest version, unlike
writing a new implementation which takes time and tends to lag behind.
As to why run it on the web, there could be various uses, for example
it could allow a simple learning environment for Python, which since
it's on the web can be entered immediately without any download (and
would run even in places where Python normally can't, like say an
iPad).

Feedback would be very welcome!

- azakai



More information about the Python-list mailing list