Slow Python - what can be done?

Lothar Scholz llothar at web.de
Fri Mar 19 15:33:51 EST 2004


sewall93 at rocknroll.umcs.maine.edu (Jason) wrote in message news:<480e9240.0403180943.64bee13d at posting.google.com>...
> Hey,
> 
> I'm an experience programmer but new to Python. I'm doing a simple
> implementation of a field morphing techinique due to Beier and Neely
> (1992) and I have the simple case working in Python 2.3 - but it's
> REALLY slow.
> 
> Basically, you specify two directed line segments in the coordinate
> system of a raster image and use the difference between those two
> lines to transform the image.
> 
> for a 400 x 600 image, python takes about 30 seconds to run the
> algorithm. This seems way to slow - I would expect it to run in a
> matter of a few seconds. Here's the code: what should I do to speed
> things up? I know I'm going to get a "do it in C/make a C extension"
> but that defeats the purpose: I'd like to know what Python can do
> here.

If you can't go with the mentioned compilers (psycho) or libraries
there is nothing else then writing C. Python is best at glueing code
together. Writing numerical or highly mathematical algorithms in
python will always result in 10000% overhead.

Maybe you want to look at GNU eiffel (smarteiffel). 

Remember there is no silver bullet !



More information about the Python-list mailing list