Performance question about math operations

Terry Reedy tjreedy at udel.edu
Tue Jul 2 12:14:51 EDT 2002


"Andrew P. Lentvorski" <bsder at mail.allcaps.org> wrote in message
news:mailman.1025589663.1583.python-list at python.org...
> I have a VLSI layout editor written in Python.  At its core, it has
to
> redraw a lot of polygons.  This requires a lot of coordinate
conversion
> mathematics.  Essentially the following loop:
...
> That's about a factor of 30 (1.5 / .05) difference even if I cancel
out
> the loop overhead.  I could handle factor of 2 or 4, but 30 seems a
bit
> high.
>
> What is eating all that time?

Among other things, boxing and unboxing the floating point numbers (as
PyObjects) and determining that +-*/ are floating point operations
rather than anything else.

>  And can I do anything about it?

Use numerical Python extensions which works with arrays of unboxed
floats and which only has to interprete +-*/ once each for entire
array and then calls c code for entire array.  Or check out SciPy
which includes numPy  and more.  Or even PyGame which interfaces to
c-coded transforms and which would aid graphical display of layout.

Terry J. Reedy







More information about the Python-list mailing list