(return to David's Python Resources)

SPIRO - Simple Python Interface to Remote Objects

Introduction

SPIRO is an simple ORB (Object-Request Broker) which allows objects to be shared between two or more python (and/or Jython) processes.

I wrote it because I wanted a bridge between cPython and Java - existing ORBs like Pyro do not yet support running servers in Jython (owing to Jython's current lack of a select() function). And, JNI-based wrappers like JPE are too brittle and create deployment problems.

Example session (client-side, c-python) - study each line carefully to see the ramifications:
$ python
>>> import spiroclient
>>> c = spiroclient.SpiroClient("fred")
>>> c.dir()
()
>>> c.do("import java")
>>> c.dir()
('java',)
>>> c.java
<java package java at 22572221>
>>> java_sqrt = c.java.lang.Math.sqrt
>>> java_sqrt
<java function sqrt at 24918414>
>>> java_sqrt(16)
4.0
>>>
      
Or more simply:
$ python
>>> import spiroclient
>>> c = spiroclient.SpiroClient("fred")
>>> c.dir()
()
>>> java = c.doimport("java")
>>> java
<java package java at 22572221>
>>> sqrt = java.lang.Math.sqrt
>>> sqrt
<java function sqrt at 24918414>
>>> sqrt(16)
4.0
>>>
      
Yes, as you can see, we have C-Python manipulating java objects!


Feature Summary


Status


Download


David McNab
Last modified: Wed Apr 14 15:41:24 NZST 2004