On Aug 7, 6:38 am, [EMAIL PROTECTED] wrote: > On Aug 7, 2:05 am, "Jack" <[EMAIL PROTECTED]> wrote: > > > I know one benchmark doesn't mean much but it's still disappointing to see > > Python as one of the slowest languages in the test: > > >http://blog.dhananjaynene.com/2008/07/performance-comparison-c-java-p... > > That Python code is bad, it contains range() instead of xrange, the > big loop is in the main code instead of inside a function, uses == > None, etc. That person can try this (with Psyco), I have changed very > little, the code is essentially the same: >
Yes, this was pointed out in the comments. I had updated the code to use xrange and is and is not instead of range, == and !=, which is how the benchmark got updated to 192 microseconds. Moving the main loop into a main function resulted in no discernible difference. Testing with psyco resulted in a time of 33 microseconds per iteration. > On my PC the Java version takes 1.17 us, while the C++ version (with > MinGW 4.2.1) takes 9.8 us. > A raw D translation needs 14.34 us, while a cleaned up (that uses > structs, no getters/setters) needs 4.67 us. > I don't know why my C++ is so much slow (doing the same things to the C > ++ version doesn't change its running time much). > > Bye, > bearophile Wonder what optimisation level you are using. I to the best of my recollection used -O3 Cheers, Dhananjay http://blog.dhananjaynene.com -- http://mail.python.org/mailman/listinfo/python-list