dfdeshom / v8onpython
- Source
- Commits
- Network (0)
- Issues (0)
- Downloads (0)
- Wiki (1)
- Graphs
-
Branch:
master
dfdeshom@gmail.com <> (author)
Sat Sep 06 12:08:07 -0700 2008
README
What is it?
-----------
This is a small module that runs Javascript code go Google's V8 engine.
The module takes any valid Javascript string, compiles it, runs and returns the result of
the of the command as a (Python) string object. Think of this as eval() in Python.
This is released under the BSD license.
Prerequisites
-------------
To build this, you will need to build v8, of course. You will also need to add
the path to the library to your LD_LIBRARY_PATH. You will also need to install Cython. I am
sure this can also run on Pyrex, but I have not formally tried it yet.
Building it
-----------
$ python setup.py build_ext --inplace
$ mv v8-src/libv8.so .
This should build v8onpython.so and let you import the module.
Usage
-----
After building it, import it.
>>> import v8onpython
>>> v = v8onpython.Script()
>>> js_code = "for (i=0;i<100000000;i++){\n j=i+1\n}"
>>> v.compile(js_code)
'1000000'
>>> v.compile("'Hello' + ', World!'")
'Hello, World!'
>>> v.compile("1.32w")
>>> 'SyntaxError: Unexpected token ILLEGAL'
That's all!
What would be cool
------------------
* Code contributions
* Performance numbers of CPython vs JS on V8.
* expand this and make Python and JS talk faster using native strings, integers
objects, etc

