Python and STL efficiency

skip at pobox.com skip at pobox.com
Tue Aug 22 16:40:54 EDT 2006


    Tim> But beware! For Python2.5 I had to change the code slightly,
    Tim> because it already realized that the expression

    Tim> '%s' % 'something'

    Tim> will be a constant expression, and evaluates it once only... so I
    Tim> had to replace '%s' with a variable, and I got the timings above
    Tim> which show Python2.5 to be slightly faster than Python2.4.

Shouldn't you then get rid of any compiler optimizations your C++ compiler
does?  Why penalize 2.5 because it recognizes a useful optimization?

    Tim> (Next step would be to create a VB version and a Java version of
    Tim> the same program, oh and perhaps to try a version that would work
    Tim> with Jython... perhaps somehow w/o the 'set')

I don't recall the example exactly, but couldn't you just create a set class
that uses a dict under the covers and only implement the methods you need
for the test?

Skip



More information about the Python-list mailing list