return \@array or @array

Jérôme Étévé jerome.eteve at
Thu Sep 12 15:02:27 BST 2013

Hi all,

I reckon there's a popular belief going around that A is "faster" than B

sub fA{ ... ; return \@array; }
sub fB{ ... ; return @array; }

foreach my $thing ( @{fa()} ){ ... }
foreach my $thing ( fB() ){ ... }

My almost blind faith in the Perl internals gives me the gut feeling
that as arrays are a very native Type in Perl, and the underlying AV
holds a reference anyway (at the end of the day, it's C..), it
shouldn't make much difference.

And that building a Perl reference of something that's already a C
space reference isn't going to help much.

Any insight?



Jerome Eteve

More information about the mailing list