Ask a Question related to PERL Miscellaneous, Design and Development.
-
Ethan Brown #1
Array slicing through a reference: Inefficient?
Dear Group--
I'm working on a project where I'm working with large arrays, and I'm
using references to pass arrays around to reduce memory use as much as
possible. I often work with small subsets of a referenced array and
access it like:
my @subrange = @{$big_array_ref}[$start_idx .. $end_idx];
Also, to get the array size, I'll do:
my $num_points = @$big_array_ref;
Is this the best practice? Do I need to be concerned in a statement
like
@{$big_array_ref}[$start_idx .. $end_idx];
that the array referenced by $big_array_ref is being completely copied
before the subrange is taken? Likewise for the $num_points example.
Thanks,
--Ethan Brown
--Keyboards: "The Fabulous Pelicans" ([url]www.pelicans.com[/url])
--In a band? Use [url]http://www.WheresTheGig.com[/url] for free.
Ethan Brown Guest
-
Array Reference
This loop does not seem to like the reference to the array via application.production.getWorkLoad() where i is the index. Is there a way to... -
Can't reference array that exists....i checked!
Scenario: frame 1 i create array called xml_array; I then fill array with other arrays, creating a 2 dimensional array. easy enough. So i... -
list ($d, $row) = each ($array) by reference?
Hi ! I always thought that while (list($d,$row) = each($array)){ $row = 5; } would operate by reference, so that $array is filled with 5... -
Array Reference Practice Help
Is this a standard/normal/ok way to pass and use array by reference? @alpha=("a","b","c"); @numer=(1,2,3); #calling by reference... -
Couple of array/reference type questions
There are several array type things I find myself doing all the time and I'd like to know, once and for all, the best way to do them. For the... -
Tassilo v. Parseval #2
Re: Array slicing through a reference: Inefficient?
Also sprach Ethan Brown:
There is no need to worry here. If you have a reference to an array,> I'm working on a project where I'm working with large arrays, and I'm
> using references to pass arrays around to reduce memory use as much as
> possible. I often work with small subsets of a referenced array and
> access it like:
>
> my @subrange = @{$big_array_ref}[$start_idx .. $end_idx];
>
> Also, to get the array size, I'll do:
>
> my $num_points = @$big_array_ref;
>
> Is this the best practice? Do I need to be concerned in a statement
> like
>
> @{$big_array_ref}[$start_idx .. $end_idx];
>
> that the array referenced by $big_array_ref is being completely copied
> before the subrange is taken? Likewise for the $num_points example.
this means that the actual array also exists somewhere and you just
happen to access it through a reference. You're not duplicating any
arrays and no temporary huge arrays are built either.
Tassilo
--
$_=q#",}])!JAPH!qq(tsuJ[{@"tnirp}3..0}_$;//::niam/s~=)]3[))_$-3(rellac(=_$({
pam{rekcahbus})(rekcah{lrePbus})(lreP{rehtonabus}) !JAPH!qq(rehtona{tsuJbus#;
$_=reverse,s+(?<=sub).+q#q!'"qq.\t$&."'!#+sexisexi ixesixeseg;y~\n~~dddd;eval
Tassilo v. Parseval Guest
-
pkent #3
Re: Array slicing through a reference: Inefficient?
In article <vr1xufl44l.fsf@draupnir.gso.saic.com>,
Ethan Brown <ethan@draupnir.gso.saic.com> wrote:
As far as I know - but I haven't read the friendly source - the array is> Is this the best practice? Do I need to be concerned in a statement
> like
>
> @{$big_array_ref}[$start_idx .. $end_idx];
>
> that the array referenced by $big_array_ref is being completely copied
> before the subrange is taken? Likewise for the $num_points example.
not copied. In other words you're saying to perl "give me the slice
$start to $end from the array _pointed to_ by $arrayref". So I'd say to
you: don't worry , I think you're doing things the right way
P
--
pkent 77 at yahoo dot, er... what's the last bit, oh yes, com
Remove the tea to reply
pkent Guest



Reply With Quote

