embedding jython in CPython...

Steve Menard foo at bar.com
Sun Jan 23 01:13:01 EST 2005


Jim Hargrave wrote:
> Sorry - should have given more detail.  That's what I get for posting at 
> 1:00AM.
> 
> What I want to do us write scripts in CPython that access Windows 
> ActiveX such as Word and IE. Obviously Jython can't do this (easily at 
> least). I also have Jython scripts that provide a high level layer on 
> top of various Java libraries. I'd like to write as much code in Python 
> as possible. But I have a mixture of incompatible CPython and Jython 
> scripts - that's why I would like to embed Jython in CPython. If I can 
> call my Jython scripts from CPython I can have the best of both world's!
> 
> Would I be able to embed Jython using JPype? The PyLucene approach 
> (compile Java source with GCJ then wrap with SWIG) looks interesting - 
> but complicated.
> 
> Here's an example of embedding Jython in a regular Java app:
> http://www.jython.org/docs/embedding.html
> 
> Imagine doing the same in CPython, but with JPype or GCJ/SWIG.
> 
> 
> 

Certainly! As far as JPype is concerned though, Jython is just another 
library. What I mean is, the API to lauch your Jython scripts will be 
identical JPype as though coded in Java. There will be no "magic" to 
bridge CPython and Jython.

The obvious advantage of going that way though, instead of the GCJ 
approach, is that you keep the full dynamicity of Jython.

I am curious to know what makes your Jython code incompatible with 
CPython. If it is only because it uses Java classes, it might not be too 
difficult to port them to CPython+Jpype.

Let me know if you need any help.

-- 
Steve Menard
--------------------
Maintainer of http://jpype.sourceforge.net



More information about the Python-list mailing list