[reportlab-users] Performance problem for lineplots with many values (with possible solution)
robin at reportlab.com
Wed Jan 30 13:02:00 EST 2013
On 30/01/2013 10:17, Sebastian Messing wrote:
> I tried to generate a lineplot with joinedLines=1. The lineplot has three lines,
> each line with 86000 values. The generation of the lineplot is very, very slow
> I use ReportLab 2.6 but I also found the problem in ReportLab daily from
> 01/29/2013 in /src/reportlab/graphics/charts/lineplots.py:
> 276 # Iterate over data columns.
> 277 if self.joinedLines:
> 278 points = 
> 279 for xy in row:
> 280 points += [xy, xy]
> If I use a list comprehension instead, the plot is generated within seconds or
> 278 points = [[xy, xy] for xy in row]
> Also linecharts.py contains the same performance problem but I don't use that.
> Best regards
> Sebastian Messing
A Python lister looked at my tests of your code and points out that the list
comprehension is not equivalent to the loop.
The loop produces [a,b,c,d,.....] whereas the comprehension is producing
[[a,b],[c,d],.....], in this case we want the flat list of points because the
Poly functions take [x0,y0,x1,y1,....] type lists of numbers.
More information about the reportlab-users