See All Titles |
![]() ![]() Welcome to JPythonJPython is a Java implementation of the object-oriented scripting language called Python that has been certified as 100% pure Java. In other words, JPython does not use any of the C code of the original Python implementation. It is a version of Python that runs on top of the Java Virtual Machine. Thus, it allows you to run Python on any Java platform and enables your JPython applications to have access to any Java library that you might need. JPython offers the same language as Python, but it has a different implementation. Python is a scripting language whose interpreter is written in C, which means that this implementation is called CPython. On the other hand, JPython re-implements the Python parser and interpreter in Java. Actually, the interpreter is available as a Java application, which allows Python programs to be created and seamlessly integrated with the Java platform. Note however that both types of implementation (Python and JPython) have their own pace. Efforts are made to keep them in sync, but it is not guaranteed that this will always happen. JPython carries a license that complies with the Open Source definition. It is freely available for both commercial and non-commercial use and is distributed with source code. JPython was designed by Jim Hugunin, who is also the main author of the Numeric Python extensions. He has joined Guido at CNRI in 1998, leaving in mid-1999 to join the Xerox PARC team in California. When he left, Barry Warsaw took care of the JPython project, and he is the main person responsible for the project since then. Currently, JPython is maintained by Warsaw at BeOpen Python Labs. At the Web site, you can always obtain the latest information about this implementation and download info. In case you are interested in downloading the source code, it is available via CVS. The latest version of JPython was released in January of 2000. Check out the JPython Official Web site at If you want to be in touch with other users, JPythoners have their own mailing list that you can use to discuss JPython, ask questions, and help other users as well. Check out the jpython-interest mailing list at http://www.python.org/mailman/listinfo/jpython-interest JPython FeaturesJPython's core is an interpreter engine, similar to CPython's, that provides support to the greater part of the Standard Python Library. JPython has a set of features that includes
JPython uses the Java's introspection mechanism to understand the contents of the package, which means that when you want to import a Java library, say something such as import java.awt JPython first tries to find a Python package named java. And in case it doesn't find one, it uses the Java mechanism to search in the CLASSPATH system variable for a .class or .jar file that meets the requirement. Another important aspect of JPython is that you can create JPython classes that subclass Java classes, extending JPython functionality without the need for using wrapper generators (such as SWIG—Simplified Wrapper and Interface Generator), provided the functionality is already implemented in Java code. Otherwise, you probably need to use the JNI interface to make the code available to JPython. This allows you to easily use the same set of classes that a regular Java application has access to. The opposite is also true. Java has total integration with JPython, and because JPython is 100% pure Java certified, you might embed JPython in your Java applications without any worries of compromising the portability of your application. If necessary, you can even pass JPython object instances back to Java (executing callbacks), and manipulate these instances in the Java application because any Java code that processes Java objects is also able to process JPython objects. Sometimes, you might find JPython useful for testing your Java components. As JPython has total integration to the Java implementation, you can use it to call, test, and debug the functionality of Java functions through the interpreter. JPython is the perfect choice for controlling Java through an interactive language. JPython also handles memory management with care in order to remove from you the responsibility of being worried about object circular references. To do so, it uses the power of the Java memory management mechanism, a mechanism that implements a garbage collector, which is executed at runtime. JPython's performance is still not as good as the performance of CPython, but there is a lot of effort going on in order to make JVMs run faster. CPython Versus JpythonBoth CPython and JPython are implementations of the same language: Python. Even though the development team tries to make both codes as compatible as possible, differences are inevitable. Each one of these languages is written using a different programming language: C and Java, respectively. This primary difference is more than enough to cause both codes to have many distinctive characteristics that are unlikely to disappear soon. The following is a short list of differences between both implementations:
The following Web page shows all known differences between the two implementations of the Python language, including the ones listed in this topic: http://www.jpython.org/docs/differences.html JPython Resource LinksA collection of Web links that provide useful information about JPython are as follows:
|
Index terms contained in this sectionBeOpen Python LabsCPython vs. JPython 2nd Hugunin, Jim introspection mechanism Java mechanism JPython 2nd 3rd 4th CPython vs. 2nd Web resources programming languages CPython vs. JPython 2nd JPython 2nd 3rd 4th CPython vs. 2nd Web resources Warsaw, Barry |
© 2002, O'Reilly & Associates, Inc. |