How naive is Python?

skip at pobox.com skip at pobox.com
Mon Jan 15 16:13:17 CET 2007


    John> Sorry, Skip, but I find that very hard to believe. The foo()
    John> function would take quadratic time if it were merely adding on
    John> pieces of constant size -- however len(str(i)) is not a constant,
    John> it is O(log10(i)), so the time should be
    John> super-quadratic.

Sorry, I should have pointed out that I'm using the latest version of
Python.  I believe += for strings has been optimized to simply extend s when
there is only a single reference to it.

Skip



More information about the Python-list mailing list