Maric Michaud wrote: > Le mardi 22 août 2006 12:55, Mc Osten a écrit : > > In fact Python here is faster. Suppose it has a really optimized set > > class... > > Maybe I'm missing something but the posted c++codes are not equivalent IMO to > what python is doing. I discarded the "slow" version, and tried to get the > equivalent in c++ of : >
Your C++ version got me the following timings (using gcc 3.4.5 as the compiler, MinGW version, with -O6): [EMAIL PROTECTED] ~/My Documents/Python $ ./testcpp.exe print_occurence_of_strings What do you know? chicken crosses road fool so long... print_occurence_of_unique_strings What do you know? chicken crosses road fool so long... print_occurence_of_unique_strings_compared_by_address What do you know? chicken crosses road fool so long... strings : 2.135 unique strings : 1.103 compared by address : 0.21 For reference, Python's best time was 0.39 seconds on the same computer (in the 'fast' version, using only 4 unique string instances). Hmmm... Can we conclude now that carefully crafted C++ code is about twice as fast as casually and intuitively written Python code? ;) (Just kidding here of course) NB: Your code now tests for address-equality. Does it also still test for string-equality? It looks to me that it does, but it's not quite clear to me. Cheers, --Tim -- http://mail.python.org/mailman/listinfo/python-list