is c faster?

Paul Hughett hughett at mercur.uphs.upenn.edu
Sun Jun 10 14:02:45 EDT 2001


Sean 'Shaleh' Perry <shalehperry at home.com> wrote:

: On 09-Jun-2001 akhar wrote:
:> I have a script I wrote in python , I love the time it took me to  devellop
:> it faster than i could have done it in C. however after full review of my
:> code I am not sure I can optimize it any more( it basicaly consist of
:> importing an image and tranforming into a matrix to perform some for-looped
:> operations on it) : I went from 20 seconds to 2. I can't seem to bring the
:> execution time down :( . would C code be faster? by what factor? can I
:> optimise my code more? how?
:> 

: the C version COULD be faster.  However, have you tried some of the python
: imaging libs?  Many of them are implemented in C.

: Another option is to put the heavy computation in C, wrap it with your 
: existing python and get the best of both worlds.


For an example, see the bblimage package at

http://www.med.upenn.edu/bbl/publications_downloads/downloads/software.shtml

This package uses Python as a scripting language to control a C
library optimized for high performance on multi-dimensional images.
It will do a lowpass filter on a 256 x 256 x 256 image in a few
seconds, using only a few lines of Python code.


Paul Hughett



More information about the Python-list mailing list