CPython to LLVM to Javascript - Python in the browser

  • It's kind of fascinating to peruse the generated js, if you are at all familiar with the CPython code:

    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'

  • It's an interesting proof of concept. I did a quick "benchmark" by calculating the 30th Fibonacci number with a dumb recursive implementation and there was a 60-70x difference in speed. I wonder how much of the speed difference is solvable and how easy it would be to have a DOM API.

  • Have you tried it with Firefox pre 4.0? Doesn't seem to work on 3.6.13.

    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.

  • That page causes my FF4b9/OSX to crash, FYI.

  • Can it run NTLK http://www.nltk.org/ ?

  • I think this is pretty awesome. Language compilation is a fascinating topic.

  • There used to be a client side python active x control for I.E.