where are the program that are written in python?

Tim Chase python.list at tim.thechases.com
Sat May 22 07:28:36 EDT 2010


On 05/22/2010 02:43 AM, sturlamolden wrote:
> That only applies to CPU bound program code (most program code is I/O
> bound), and only to computational bottlenecks (usually less than 5% of
> the code) in the CPU bound programs. Today, most programs are I/O
> bound: You don't get a faster network connection or harddrive by using
> C. In this case, performance depends on other factors than choice of
> language. That is why Mercurial (written in Python) can be much faster
> than SVN (written in C).
>
> For computational bottlenecks we might want to try high-performance
> numerical libraries first. If that does not help, we can try to
> replace some Python with C.

Just as an aside, last I checked, mercurial had some core code in 
C for speed.  But that doesn't negate your line of reasoning, 
rather it cements it -- they found it was most productive to work 
in Python, but needed the core bits to improve in speed so 
rewrote them in C.

I'd also include that a change in algorithm can be a big help for 
speeding up CPU-bound code.  It doesn't matter much if you're 
using Python or hand-coding that inner loop in C/ASM, if you're 
using a O(2^N) algorithm.  I find it easier to write good/speedy 
algorithms in Python because I have a toolkit of built-in 
data-types (sets, dicts, lists, etc) that I can reach for, 
without making sure I've added-on certain C libraries.

-tkc



More information about the Python-list mailing list