(More Than) Five Things You Didn't Know You Could Do With Python - ' High' (
Page 4 of 5 )
-Performance Python">
High-Performance Python
By some measures, Python is only about a hundredth as swift as corresponding C programs — at least for simple numeric loops and calculations. From a project standpoint, though, the interesting comparison is between the speeds of actual programs delivered in both languages.
Seen that way, Python needn't apologize for its speed or the apparent lack of it. What I've observed happen many times in commercial and scientific practice is that a Python-coded application is not just adequately fast, or almost as fast, as its C or C++ counterpart, but faster.
Two factors are usually at play here. First, Python does quite well at things programmers need and use. C programmers required to handle arbitrary end-user data often write their own linked lists and associated algorithms, and end up risking that a tiny flaw in implementation will slow down operations dramatically. Python builds in associative arrays (among other datatypes). C's performance lead is fragile, in that it typically depends on quite a bit more application-specific code working as intended.
That's related to the second factor which boosts Python: Python programmers finish their work faster. Python is quite productive, according to nearly all measurements. This makes Python projects more manageable, and allows for more experimentation, redesign, and whole-system engineering. These aspects of "implementation in the large" can and do lead to algorithmic improvements of many orders of magnitude, not just the one or two that C gains with its low-level coding.
As already mentioned above, the top applications often involve a medley of languages. One of Python's early publicity successes was the supercomputing work done in the mid '90s by
David Beazley, author of Python Essential Reference, and his colleagues. That team wrote fast physics simulations because of Python, not in spite of it.