Thursday, January 15, 2009

New in Jython 2.5b1: elementtree, Java Integration overhaul

Sébastien Boisgérault's jython-elementtree project was incorporated into the recent Jython 2.5b1 release.

It doesn't implement any actual elementtree code, but instead provides a partial implementation of the pyexpat module (which the pure Python elementtree is built upon) in a clever 600 lines of Python code.

This provides full support for elementtree but also improves compatibility with code using pyexpat. For example, the standard lib's xmlrpclib module takes advantage of pyexpat for faster XML parsing if the module is provided. Jython may never fully support every pyexpat feature, but this is a great step towards supporting libraries like Genshi, among others.

Unfortunately jython-elementtree requires the latest Xerces: an additional 1mb jar. Xerces also seems to have also introduced some classpath issues, which is just about as cliche as you can get in Java.

The 2.5b1 release also includes an overhaul of Java Integration. It's now based on new style classes, which is very important going forward.