Hackish experiment in interprocess communication. It allows Python to "call" JavaScript functions.
Create a Python virtualenv and activate it. Then:
npm install
Check out py_calling.py
. It uses a library called xipc
, which is in this repo. The top-level with
statement "imports" four modules:
Then, it calls functions in these modules. The Python and JavaScript variants of each function return the same results, which you can see from the CLI output.
$ python py_calling.py
Two values should be the same: 3 3
Two values should be the same: -1 -1
Two values should be the same: {'fortune': 'Your name was, is, or will be Mike.'} {'fortune': 'Your name was, is, or will be Mike.'}
Check out js_calling.js
. It uses a library called xipc
, which is in this repo. The top-level function "imports" four modules:
Then, it calls functions in these modules. The Python and JavaScript variants of each function return the same results, which you can see from the CLI output.
$ node js_calling.js
Two values should be the same: 3 3
Two values should be the same: -1 -1
Two values should be the same: { fortune: 'Your name was, is, or will be Mike.' } { fortune: 'Your name was, is, or will be Mike.' }
Run:
$ python prof.py
Time in seconds for 1000 additions using sockets: 0.17347383499145508
Time in seconds for 1000 additions: 0.0
$ node prof.js
Time in seconds for 1000 additions using sockets: 0.681
Time in seconds for 1000 additions: 0