Mc Osten wrote: > Tim N. van der Leeuw <[EMAIL PROTECTED]> wrote: > > > Oh boy; yes indeed the slow python is faster than the fast C++ > > version... Must be something really awful happening in the STL > > implementation that comes with GCC 3.4! > > And the Python version does the very same number of iterations than the > C++ one? I suppose they are looping on arrays of different sizes, just > like my "first version". >
Hmmm.. You're quite right. The C++ version had an array size 100.000 (your version), the Python version still had an array size 10.000 (as in my modified copy of the original version). When fixing the Python version to have 100.000 items, like the C++ version, the Python timings are: Begin Test Number of unique string objects: 4 so long... What do you know fool chicken crosses road Number of unique string objects: 400000 so long... What do you know fool chicken crosses road Fast - Elapsed: 0.512088 seconds Slow - Elapsed: 1.139370 seconds Still twice as fast as the fastest GCC 3.4.5 compiled version! Incidentally, I also have a version compiled with VC++ 6 now... (not yet w/VC++ 7) .. Compiled with release-flags and maximum optimization for speed, here's the result of VC++ 6: [EMAIL PROTECTED] ~/My Documents/Python $ ./SpeedTest_VC.exe Begin Test What do you know? chicken crosses road fool so long... What do you know? chicken crosses road fool so long... Fast - Elapsed: 4.481 seconds Slow - Elapsed: 4.842 seconds So you can see that it's 'slow' version of the code is faster than the 'slow' version compiled with GCC, but the 'fast' code is barely faster than the 'slow' code! And the 'fast' version compiled with GCC is much faster than the 'fast' version compiled with VC++ 6! My conclusion from that is, that the vector<> or set<> implementations of GCC are far superior to those of VC++ 6, but that memory allocation for GCC 3.4.5 (MinGW version) is far worse than that of MSCRT / VC++ 6. (And Python still smokes them both). Cheers, --Tim > -- > blog: http://www.akropolix.net/rik0/blogs | Uccidete i filosofi, > site: http://www.akropolix.net/rik0/ | tenetevi riso e > forum: http://www.akropolix.net/forum/ | bacchette per voi. -- http://mail.python.org/mailman/listinfo/python-list