Speed of string += string
Marcus Alanen
marcus at infa.abo.fi
Mon Apr 14 06:40:38 EDT 2003
On Sat, 12 Apr 2003 20:14:51 -0400, Roy Smith <roy at panix.com> wrote:
>One of the very few things I like about C++ over Python is that the STL
>is very careful to document the complexity of the various operations.
>AFAICT, no such documentation exists for Python.
Indeed, that was the first thing I wondered about when I started
learning Python.
>As another example, I can guess that Python dictionaries work like STL
>maps on the inside, but that would be just a guess. Is inserting an
>element logN? Is keys() linear? Is del on an element logN? Is
>has_key() logN? Those would be my guesses. But they're just guesses.
Others answered this very thoroughly, I'd just like to emphasize the
linearity of keys() --- most often you can manage with .iterkeys() or
.itervalues() just fine, and it's a lot faster.
--
Marcus Alanen
maalanen at abo.fi
More information about the Python-list
mailing list