is c faster?

Courageous jkraska1 at san.rr.com
Sat Jun 9 14:13:10 EDT 2001


>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...?

Not really, no. I often get about a factor-of-6 speed up or so for
the things that I choose to externalize. This does, of course, imply
a certain amount selection bias on my part.

On a more general level, one should generally only select to
externalize functions which are "computationally intense". Frequently
invoked functions with low computation time won't generally
benefit much from externalization, because of the Python interpreter
dispatch overhead. This often applies to simple O(n) operations
where n == 2000 or more; for example, I would not expect a simple
linked list to outperform a python "list" (i.e., vector) on insert until
n >= 2000 or more.

C//



More information about the Python-list mailing list