[reportlab-users] Is the graphics package slow?

Dinu Gherman reportlab-users@reportlab.com
Mon, 29 Mar 2004 23:34:52 +0200


Sebastien Lemieux:

> I'd like to know if I'm doing something obviously wrong in my code and
> if any of you see a way to accelerate the process?

A low-cost optimization would be the following (untested, though).
Please let me know how much faster it actually is... ;-)

Dinu


data = []
app = data.append                ##
for i in xrange(1000):           ##
	app((random(), random()))   ##

def Scatter(fn):
	d = Drawing(400, 400)

	add = d.add                 ##
	for (p0, p1) in data:       ##
		x = 400 * p0           ##
		y = 400 * p1           ##
		add(Circle(x, y, 2.2)) ##

	renderPM.drawToFile(d, fn, 'PNG')