is c faster?

Alex Martelli aleaxit at yahoo.com
Tue Jun 12 04:23:00 EDT 2001


"Chris Barker" <chrishbarker at home.net> wrote in message
news:3B2550F5.ED7F54D at home.net...
> Alex Martelli wrote:
> >  a speed up as small as 20%
>
> That must have been disapointing!

I didn't expect much more, actually -- it was just an
experimental attempt to see what I could do to speedup
some intricate re-based function.  The bottlenecks, and
I knew that, were in the re code, so I was just pruning
away a tiny bit of loop overhead, method-lookup &
whatnot.  I think this is the kind of benefit one
might expect from a simpleminded 'compiler':-).  (Happy
End: I rethought the whole approach in terms of string
scanning rather than re's and the bottleneck went away:-).


> > 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
>
> I got an approx 100X speedup in my only substantial extension (still not
> that big). I was already using NumPy arrays, but there was just no way
> to "vectorize" the whole thing. I may have been able to get a 10X
> speed-up or so keeping it in just Python if I put some time into it, but
> I knew I wasn't going to get what I needed, so I went to C.

So, the roughly-ten-times ratio (between speediest fine-tuned
Python and C) might still apply here (maybe)...


Alex






More information about the Python-list mailing list