CPython vs. Jython/JPython

Guido van Rossum guido at beopen.com
Mon Oct 30 21:32:08 EST 2000


You are all wrong. :-)

The key difference between CPython and JPython is not speed, but
available extensions.  CPython is useful as a glue language for C/C++
library code.  There are lots of examples, e.g. NumPy, Tkinter, PIL,
and so on.  JPython is useful as a glue language for Java library
code, e.g. Swing, JavaBeans, Jave 2 Enterprise Edition APIs, and so
on.

If only CPython existed, linking to Java code would be very
cumbersome: you'd have to wrap a JVM in a CPython extension and take
it from there.  If only JPython existed, linking to C/C++ code would
be impossible (in situations where JNI is not available) or at best
cumbersome (wrapping C/C++ code in JNI is much more painful than
writing Python wrappers, because of the JVM's garbage collector).

It's sometimes possible to use C/C++ code from JPython (e.g. Finn Bock
did a wrapper for _tkinter) but rarely convenient.  I haven't heard of
anyone linking to a JVM from CPython.

Of course, the fact that there are two different implementations means
that an app that requires the use of both a library written in C/C++
and one written in Java is out of luck.  Fortunately, most of the
standard extensions (e.g. regular expressions) are available in both
CPython and JPython.

In the rare case where you need two non-standard extensions, you could
write your program as two communicating processes, one using JPython,
one using CPython.

--Guido van Rossum (home page: http://www.python.org/~guido/)



More information about the Python-list mailing list