How can you copy (clone) a string?
Fredrik Lundh
effbot at telia.com
Tue Oct 3 11:21:11 EDT 2000
Peter.Rupp at ual.com wrote:
> Earlier I asked a question about cloning python strings, but neglected
> to say why I needed it.
>
> What I'm trying to do is determine how large a user process can be
> before it runs out of memory. This is useful in debugging kernel
> parameter issues in our performance lab where our tests are running out
> of memory and I have to provide empirical proof that the kernel parms
> are set correctly and that an example program can prove it.
oh, now you're telling us ;-)
forget about strings. use the array module instead (it basically
implements mutable strings). here's an example:
import array
bloat = [array.array('c', '*'*1000000)]
while 1:
print len(bloat), "..."
# consume another meg
bloat.append(bloat[0][:])
</F>
More information about the Python-list
mailing list