[reportlab-users] [Jython2.5.1] issue: Invalid method Code length 656615 + patch proposal
Robin Becker
robin at reportlab.com
Wed Feb 10 13:13:32 EST 2010
On 10/02/2010 13:07, Raphaël Valyi wrote:
> Hello guys,
>
> I should say I'm sad to see that despite I provide you that trivial patch
> one year ago on that mailing list and you still did nothing for Jython,
> despite even the clear failure of Unladen Swallow to save CPython (only 1.5
> faster at best while using more memory; JRuby is 5x faster than CRuby, aside
> from JRuby lead Charles Nutter being an awesome alien, there is no reason
> why Jython couldn't offer the same advantages given a larger momentum).
>
> So, yes Andy, I confirm your point.
> Again, here is my patch http://pastie.org/818080 , this is for reportlab 2.3
> or may be a beta of it (please double check with a diff against you trunk,
> you could re-indent or use Meld for that). It doesn't actually matter,
> please just re-apply the logic of the patch to Reportlab trunk:
> I remind you the logic: because Jython will map each Python method to a Java
> method and because by specification, the JVM is limited regarding to the
> method size, we need Python programs to avoid methods that are too fat such
> as the ones found in your fontdata.py file (a general good practice in
> software engineering BTW).
>
> So, in my patch, I just wrap some fonts initialization code into
> the fill_encodings method I introduce. This does the trick and is totally
> transparent for CPython usage, so please just apply it.
> After that Reportlab seems to work on Jython.
>
> Thank you if you could play it nice with Jython this time. The JVM is an
> amazing piece of engineering, I think that's foolish to ignore it. Google
> tried to ignore it with Unladen Swallow -> they failed.
>
> Raphaël Valyi
.........
Raphaël,
we do have a jython25 branch where the code is known to run; that has your patch
in it and has for almost a year. I also emailed the jython list sometime after
the porting effort to jython2.5b1 to indicate that almost all of our tests would
now run in jython25. However, we have to support several different versions of
python and it's not at all clear that we should expect the trunk code always to
maintain compatibility with every platform (Ironpython & jython are the
exception rather than the rule for us).
I also cannot remember why this patch didn't get added; anyhow it's not very
pythonic; declaring a list/tuple inside a function for the purpose of reducing
the size of the module level code is a bit obscure. Personally, I would be more
in favour of splitting the _fontdata.py module into separate files with sensible
names for the individual font metrics.
This code isn't broken for our use, jython appears broken for a common case. If
the individual arrays had required more than 65k then even this function hack
would work.
--
Robin Becker
More information about the reportlab-users
mailing list