We're working at something relevantly similar at my firm, called GPSEE. It's using javascript, not python... but the main thing is that we have a pretty decent foreign function interface for it. The code repository for the FOSS part of gpsee is at

http://code.google.com/p/gpsee

with support available on Freenode at irc://irc.freenode.org channel #gpsee.

You'll be wanting the support as my boss freely admits that the docs at the google code page "kinda blow". That said, you can only expect to find Wes (my boss) and Donny (contract programmer that's working with us) on there during business hours EST.

Basically, there are tools there that can be used to basically import any C function easily into javascript. Note that this is javascript using the gsr (gpsee script runner) program... this is absolutely not intended for use in the browser and almost certainly will never be in a browser due to the rather obvious security implications. This is intended for compatibility with the CommonJS (formerly ServerJS) framework. We are already using some of this in production, and if your platform supports the nano-JIT compiler it can result in some serious serious performance out of it.

Since javascript is at heart a functional language, the basic approach is to include C functions under a special object, and then we wrap those functions as appropriate in javascript objects using javascript to do so. We are already using some of this in production in a high-traffic high-availability environment without problems.

My personal take on this particular project is that once it gets known within the wider community my boss is going to become a programming star; you can include any arbitrary existing C function into the javascript interpreter with about a half-hour of C programming, mostly to create the necessary structures for storing arguments and returns from those C functions. Type promotion is largely done in a sane manner; for example, if a C function returns NULL it will be automagically promoted to the null object in javascript, etc etc etc.

If anyone wants to go check it out (and maybe help out) please feel free to visit the site and channel above.

Cheers,

Jack