Perl inefficiency...

Linda Walsh
Wed Jan 24 21:08:00 GMT 2007

$a="a";          (uses 2 Bytes)
$a="a" * 100Meg; (uses 200MB)
$b="b" * 100Meg;

I may be reading this incorrectly, but I don't think the question
is why storage for the separate strings "$a", "$b" isn't freed, but
why would perl use 2 bytes/character?  I thought perl used UTF-8
internally(?).  Shouldn't it be using closer to 100MB to store
100-Million chars?

Of course if perl had a "use-less-memory" pragma, I might even
"hope" that it would store the above string as a repeat-count
followed by the string...but that would be expecting a bit...

I understand perl may not be as efficient in data storage as
C, but seems like expanding a 100MB string to take 200MB is
wasting 100MB. 

Is this what you were referring to, Corinna?


Unsubscribe info:
Problem reports:

More information about the Cygwin mailing list