Renting CPU time for a Python script

Fernando Perez fperez528 at yahoo.com
Sun Jul 21 15:40:18 EDT 2002


> Thanks for your very informative post!  Unfortunately the bottleneck
> in my program lies with the PIL extension since I have to perform a
> lot of putpixel and getpixel operations, which are quite expensive in
> PIL.  In the future I would like to rewrite sections of the code in C,
> but I have to admit that dealing with LibTiff greatly exceeds my C
> programming abilities.  I really like your idea of building in
> restarting functionality, and I will add it when I get some free time.

It's hard to say without knowing the details of your problem, but I'm a 
bit surprised to hear that you're doing compute-intensive operations on 
an image format. So forgive me if I'm off-base, but I suspect your 
problem could be fixed by moving away from image formats to a numerical 
representation of your data. Convert your data to matrices, and then 
operate on them using either Numeric (fast) or with a few hand-written 
extensions using weave (possibly even faster, weave is at scipy.org).

As I said I could be wrong, but I'd be extremely surprised to find that 
the core of your problem needs to be done on the images as images and 
that it can't be expressed mathematically on the underlying matrices. 
Image formats are meant for human viewing, not for efficient numerical 
processing.

Good luck,

f.




More information about the Python-list mailing list