in reply to Re^9: Does @{ } copy arrays?
in thread Does @{ } copy arrays?
Unfortunately, none of those 'remedies' work:
C:\test>p1 [0] Perl> use Devel::Size qw[ size total_size ];; [0] Perl> @a = 1 .. 10;; [0] Perl> print size( \@a ), ':', total_size( \@a );; 256 : 496 [0] Perl> print $#a;; 9 [0] Perl> print size( \@a ), ':', total_size( \@a );; 440 : 680 C:\test>p1 [0] Perl> use Devel::Size qw[ size total_size ];; [0] Perl> @a = 1 .. 10;; [0] Perl> print size( \@a ), ':', total_size( \@a );; 256 : 496 [0] Perl> $x = 0+$#a;; [0] Perl> print size( \@a ), ':', total_size( \@a );; 432 : 672 C:\test>p1 [0] Perl> use Devel::Size qw[ size total_size ];; [0] Perl> @a = 1 .. 10;; [0] Perl> print size( \@a ), ':', total_size( \@a );; 256 : 496 [0] Perl> $x = ${ \$#a };; [0] Perl> print size( \@a ), ':', total_size( \@a );; 432 : 672
In every case, the mere mention of $#a has already caused the damage to be done. Trading 76-bytes per array to save 4-bytes per array does not make sense.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^11: Does @{ } copy arrays?
by ikegami (Patriarch) on Oct 23, 2009 at 22:56 UTC |