[pygtk] Why does draw_lines require tuples?
Andrew P. Lentvorski
Tue, 8 Oct 2002 02:44:32 -0700 (PDT)
Is there a particular reason why draw_lines only works with tuples? Why
not lists or arrays?
I ask this question because I tracked down a performance problem where I'm
doing conversions using Numeric and then plotting them using pygtk. The
conversions less than a second, but then converting the two arrays to
tuples takes 10 seconds. My code is:
screenCoordsX = self.acvt_graph2screen_x(arrayGRX)
screenCoordsY = self.acvt_graph2screen_yl(arrayGRYL)
screenCoords = map(None, screenCoordsX, screenCoordsY)
Where screenCoordsX, screenCoordsY, arrayGRX, and arrayGRYL are all
rank 1 Numeric arrays.
screenCoords is a list of tuples which draw_lines demands.
Practically all of the time is wasted in that map call.
If draw_lines simply accessed things as though they were lists, I would
simply pack the two arrays into a larger array, do a transpose, and pass
the result to draw_lines.
I'm using pygtk 0.6.9 and Python 2.2.1.