is c faster?

Alex Martelli aleaxit at yahoo.com
Sat Jun 9 13:19:03 EDT 2001


"akhar" <akhar at videotron.ca> wrote in message
news:bLiU6.8081$NU3.913665 at weber.videotron.net...
> 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

Depending on several factors, recoding a good Pythonic design
into a finely tuned C extension can give you a speed up as small
as 20% (I've never seen anything less than that, though I guess
it's possible) and as big as 1,000%, i.e., 10 times faster (again,
I haven't seen anything more than that on real code, although in
this case it's easy to do even better for code that a C optimizer
can optimize down to nothing, as is true of many benchmarks:-).

Does anybody have substantially different experiences...?


Alex






More information about the Python-list mailing list