Speed issues

Aahz Maruch aahz at netcom.com
Mon Dec 27 11:17:09 EST 1999


In article <19991227143547.A3500 at stopcontact.palga.uucp>,
Gerrit Holl  <gerrit at nl.linux.org> wrote:
>
>is an assigment slower than appending to a list?

It's not the assignment that's slower, it's string copying -- remember
that strings are immutable, so that 'o=o+c' has to make a copy of 'o'
every time you go through the loop.  Therefore o.append()/string.join()
is faster.  Note that cStringIO is even faster (by about 5%), but it
introduces a dependency on an external library.
--
                      --- Aahz (@netcom.com)

Androgynous poly kinky vanilla queer het    <*>     http://www.rahul.net/aahz/
Hugs and backrubs -- I break Rule 6

Eighth Virtual Anniversary -- 4 days and counting!



More information about the Python-list mailing list