Mc Osten wrote: > Fredrik Lundh <[EMAIL PROTECTED]> wrote: > > > Python's memory allocator is also quite fast, compared to most generic > > allocators... > > In fact also in the two "slow" versions Python outperforms C++. > I didn't notice it in the first place. > > -- > 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.
Well, I guess I'm getting really obsessed with this. But anyways. I installed MinGW on my Windows-XP (sp2) laptop. It is g++ version 3.4.5 -- ancient, yes, but on windows it's the latest available. I compiled Mc Osten's C++ program (tweaked the output a little) and ran it; ran his version of the python code too. 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! Here's the output from my console: [EMAIL PROTECTED] ~/My Documents/Python $ g++ -O3 -march=pentium-m -o SpeedTest SpeedTest.cpp [EMAIL PROTECTED] ~/My Documents/Python $ ./SpeedTest.py Begin Test Number of unique string objects: 4 so long... What do you know fool chicken crosses road Number of unique string objects: 40000 so long... What do you know fool chicken crosses road Fast - Elapsed: 0.037574 seconds Slow - Elapsed: 0.081520 seconds [EMAIL PROTECTED] ~/My Documents/Python $ ./SpeedTest.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: 2.089 seconds Slow - Elapsed: 6.303 seconds [EMAIL PROTECTED] ~/My Documents/Python Cheers, --Tim -- http://mail.python.org/mailman/listinfo/python-list