Why it is so dramatical?
Bernard Delmée
bdelmee at advalvas._ZAPME_.be
Mon Sep 2 15:59:57 EDT 2002
> > $b = '';
> > $data =
'AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAA';
> > for $a (0..0xffffff) {
> > $b += $data;
> > }
> That should result in a 1.3 GIGABYTE string.
> Watching the perl-process i see that perl doesn't use more than 1MB.
> So probably perl does some optimization for this in-fact meaningless code.
Nothing that magic: '+' does not concatenate strings. You need to use '.'
or '.=' for that. Otherwise $b keeps getting the numerical value 0 when
perl wants to use it with the arithmetic '+' addition.
More information about the Python-list
mailing list