When Python outruns C++ ...

Mathias Waack mathias-usenet at valpo.de
Tue Apr 1 04:32:44 EST 2003


Julian Tibble <chasm at rift.sytes.net> wrote:
> I would also be interested to see the code, because I recently
> wrote a similar program in C.  My program counts the number of
> occurences of each word in a file (where a word is a positive
> number of characters from a-z --- uppercase letters are
> converted to lowercase). 

As usual the more a program is IO bound the lesser is the difference 
between the used programming language or the abstraction level. And 
I'm afraid Alex didn't used IO redirection as you did.  

And for IO the C++ implementation used in the g++ has an important 
"feature": to be able to mixup any sequence of C and C++ io (ie. cout 
<< and printf) it calls a write for each single character. Disabling 
this usually gives a significant performance boost (look at 
std::ios::sync_with_stdio(false)). 

Mathias




More information about the Python-list mailing list