[reportlab-users] ReportLab Contribution

Robin Becker robin at reportlab.com
Sat Jul 8 03:42:38 EDT 2023


On 07/07/2023 18:20, Paul Barrass wrote:

Hi Paul,

thanks for your patch. Unfortunately without knowing what it fixes it's hard to say if it's correct/benefical.

Do you have an example table that illustrates the problem?

Your patch is a bit off in terms of latest reportlab, but looking at where it matches it seems as though it can only be 
that you have


self._longTableOptimize set as False

so that long tables cause a O(n**2) behaviour as they are split and re-rendered.

Latest reportlab sets the default value for longTableOptimize = 1 so the else would not be considered.

The quadratic behaviour was pointed out a long time ago by contributor Henning von Bargen.

It may still be that your patch fixes a bug, but I am reluctant to just apply it so a failer case would be appreciated.

thanks


> Hi,
> 
> I've been using the open source ReportLab for many years - I used to be slightly active on the mailing list, but haven't 
> been for years as everything has been working well, and I didn't have the time to follow along.  Hope you've been well 
> in the intervening time.
> 
> It looks like my installation auto-updated a couple of days ago to the latest version, and today I was producing a 
> document which was taking an extraordinary long time (I killed it after 90 minutes, so not sure how long it would have 
> taken).  I noticed that the installation had updated, and I remembered I'd applied a quick patch to my previous 
> installation which massively helped with large tables (multi-10k lines).  I applied the patch to the new version and the 
> document completed within a minute or so - so a massive improvement.
> 
> Unfortunately, I have no idea any more of how the change works, or how I came up with in the first place - I've included 
> it below, so you can take a look, but I can't guarantee it has no nasty side-effects, just that it works very well for 
> my use-case.  If it's of greater use, and you figure out there's no drawbacks, please consider it as a contribution to 
> your code.
> 

> Patch reportlab/platypus/tables.py :
> 
> *** tables.py.orig      2023-07-07 18:14:20.386163300 +0100
> --- tables.py   2023-07-07 18:14:27.486110602 +0100
> ***************
> *** 606,615 ****
> --- 606,617 ----
>                            #we can terminate if all spans are complete in H[:hmax]
>                            if spanCons:
>                                msr = max(x[1] for x in spanCons.keys())    #RS=[endrowspan,.....]
>                                if hmax>msr:
>                                    break
> +                         else:
> +                                 break
>                if None not in H: hmax = lim
> 
>                if spanCons:
>                    try:
>                        spanFixDim(H0,H,spanCons)
> 
> 
> 
> Hope you have good weekends,
> Paul.
> 

-- 
Robin Becker



More information about the reportlab-users mailing list