string copying

Aahz aahz at pythoncraft.com
Fri Mar 29 19:14:18 EST 2002


In article <3CA4F5CB.E8961330 at engcorp.com>,
Peter Hansen  <peter at engcorp.com> wrote:
>
>The only one I've been able to think of is the surprisingly
>common situation of trying to consume vast quantities of memory
>quickly by something like:
>
>a = [0] * 1000000
>for i in xrange(1000000):
>    a[i] = 'bigstringsuckinguplotsofmemory'

Right, and as you know, the simple way to fix this is:

for i in xrange(bignum):
    a[i] = "bigstringsuckinguplotsofmemory" + str(i)
-- 
Aahz (aahz at pythoncraft.com)           <*>         http://www.pythoncraft.com/

Why is this newsgroup different from all other newsgroups?



More information about the Python-list mailing list