Getting involved - Jython ElementTree performance

Stefan Behnel stefan_ml at
Sat Jan 7 09:40:42 EST 2012

Sophie Sperner, 07.01.2012 13:01:
> On Jan 7, 11:53 am, Stefan Behnel wrote:
>> A big issue that I have with Jython is that its ElementTree XML parser
>> support is so increadibly slow. It could seriously benefit from a better
>> integration between the Java XML support it uses and the Python ElementTree
>> module that it inherits from CPython. Considering that XML is a requirement
>> in many real world applications, especially in the Java world, you (Sophie)
>> might be interested in adding all three of Python, Java and XML to your
>> toolbox at the same time, while also learning how to benchmark and optimise
>> Java and Python code. I think that would pretty quickly get you up to speed
>> with real world software development.
> Sounds interesting. Are you a developer or user of Jython?

More of a user. I'm actually developing lxml, a fast XML library for
CPython that reimplements ElementTree. When working with Java, I try to
keep using ElementTree in Jython because it gives me a simple to use XML
interface, but it's sometimes hard to defend its use because the parser
part is so slow - several times slower than lxml would run here.

> Can you tell me more about this particular issue? Or it is easier to
> check

Here's a bit of a discussion:

The current integration is more at a "make it work" than a "make it fast"
level. Specifically, the "expat" replacement module has several problems,
also at an algorithmic level, that make it slow.

I did some benchmarking, actually not on Jython, but at least comparing
CPython and PyPy:

I posted the benchmarking code here:

You can use the attached script to see for yourself. It should also run on
Jython, so you can use it to compare the performance of ElementTree in
CPython and Jython on your own machine.

That being said, yes, I'd suggest discussing this on a Jython related list.
I cross-posted it to the jython-devel mailing list, please discuss anything
related to Jython development over there.


More information about the Python-list mailing list