mikesol / xipc

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

xipc

Hackish experiment in interprocess communication. It allows Python to "call" JavaScript functions.

Install

Create a Python virtualenv and activate it. Then:

npm install

Run Python

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.'}

Run JavaScript

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.' }

Profiling

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

About


Languages

Language:Python 60.9%Language:JavaScript 39.1%