pyv8: python v8 bindings and a python-javascript compiler

Monday, September 29, 2008 1:44

pyv8: python v8 bindings and a python-javascript compiler

pyv8 is an experimental project to combine two-way python bindings to v8 with the python-to-javascript compiler from pyjamas. a simple test has shown a ten times performance increase of python code converted and executed as javascript, when compared to running the same program as python. (to be fair, cython gives a 100 times performance increase).

sloisel has created two-way python bindings to v8: pyv8 download a version with a Makefile for linux users is here: pyv8 with Makefile

pyv8 is the project which ties pyjamas’ (pyjd.org) python-to-javascript compiler (called pyjs.py) together with python bindings to v8, and, due to v8 being able to call back out, it’s also been possible to bind back in to standard c python modules and third party c-based python modules.

the simple test, test-pyjs.py, containing a deliberately inefficient fibonacci series algorithm, gives a ten times performance increase compared to running python fib.py. the output is shown via a python-tk popup window, to demonstrate that it’s possible to call out to c-based python modules.

this is an experimental project. a much better version of pyv8 would do away with the need to use python to perform the conversion of its incoming programs into javascript – presumably by bootstrap-compiling pyjs.py itself into javascript, and running that native through something based on the v8 “shell” example rather than using python-boost to wrap libv8. under these circumstances, python-boost would only really be required to perform the bootstrap-compilation process, required for pyv8 developers and maintainers only: standard _use_ of pyv8 as a drop-in replacement for /usr/bin/python would use the precompiled javascript and the “shell”.

so whilst pyv8 is a way off from being a formal release, the significance of the performance gain, the benefits of being able to bind to standard c-based python modules. the outright simplicity of pyjs.py (only 1200 lines) makes it worthwhile letting people know that the experiment was a resounding success.

it’s also worth mentioning that pypy with its javascript back-end would also definitely benefit from using v8.

Source: advogato.org

You can leave a response, or trackback from your own site.

Leave a Reply