Your example only shows one single case. An SV can hold IV's as well as PV's at the same time and a PV representation of 1 takes less space than that of big numbers. YMMV (even with different versions of perl):
$ cat test.pl
use v5.12;
use Devel::Size "total_size";
for my $num (1, 1000, 100_000_000) {
say "Value $num:";
say total_size ($num);
say total_size (pack "w*", $num);
}
for my $num ("1", "1000", "100_000_000") {
say "Value $num:";
say total_size ($num);
say total_size (pack "w*", $num);
}
$ perl test.pl
Value 1:
64
48
Value 1000:
64
48
Value 100000000:
72
48
Value 1:
48
48
Value 1000:
48
48
Value 100_000_000:
56
48
$
Enjoy, Have FUN! H.Merijn
|