[reportlab-users] patch to make Reportlab work again on Jython

Raphaël Valyi rvalyi at gmail.com
Fri Jan 30 08:07:44 EST 2009


Dear Reportlab developers,

Context of use:

I'm an OpenERP integrator. That great (if not the greatest) ERP uses
Reportlab for all its reports, from invoices to production orders and
statistics.
After a maturing stage, it's now taking the world of ERP's by storm.
Still, in some large companies, some IT guys might be reluctant to
adopt a Python based ERP because of Python medium performance, lack of
multithreading or standardized environment like they might be used to
in the Java world. That's why I'm currently porting it on Jython, the
Java powered Python interpreter.
You might know that Jython got a new momentum in 2008 after Sun
Microsystem hired the two project leads and after JRuby proved a JVM
based interpreter + JIT compilator can totally outperform C
interpreters (up to 5 times faster on the same Ruby series).
While not as ground breaking, Jython is now certainly going there too,
probably by 2009 already (they benefit from JRuby a lot too and th JVM
will get extra instruction to boost dynamic language JIT).


Reportlab not usable directly in Jython currently:

Overall, OpenERP is fairly portable to Jython already. Still, one of
the biggest issue so far is a Jython bug preventing reportlab to load.
Actually, in reportlab, you have some large list instantiations for
font data for instance.
The trouble is that the Java JVM spec doesn't allow having a class
method larger than a certain amount of bytes.
And if there is the sum of data structure instantiations is larger
already in some Python class method, of course the method arround it
will simply blow up the Java Virtual Machine.
So yes, this is a Jython bug ( http://bugs.jython.org/issue527524 )
but it is not so easy to fix and it got a low priority because it
occurs very rarely in some very specific situations like that one with
reportlab.


Proposed patch:

So, advised by Charles Headius Nutter (the JRuby rock star who work
around the kind of issue), I came up with a patch for the reportlab
file (/reportlab/pdfbase/_fontdata.py), wrapping each of those very
large list declarations inside dumb private method so that no method
will get larger than the allowed size. I admit it, that's not
particularily elegant. But it's not too ugly either and easy to
refactor the right way when the Jython bug get fixed (after OpenERP on
Java makes Sun release how much important this is). But more
importantly, it's working and allow using Reportlab in Jython again
(at least on Jython trunk, expect release in February)!

So please could you consider including the attached patch (the whole
file actually) in your trunk distro (it's made from the trunk SVN).
I'm very sure it has not perf impact at all either. On the contrary,
running on Jython could soon give you a serious boost when everything
will JIT just as nicely as in JRuby.

What is your position regarding to this?


Raphaël Valyi
www.smile.fr
-------------- next part --------------
A non-text attachment was scrubbed...
Name: _fontdata.py
Type: text/x-python
Size: 62960 bytes
Desc: not available
Url : <http://two.pairlist.net/pipermail/reportlab-users/attachments/20090130/c13e462e/attachment-0001.py>


More information about the reportlab-users mailing list