Beefy Boxes and Bandwidth Generously Provided by pair Networks
more useful options
 
PerlMonks  

Re^3: Index or iterate - your choice

by tobyink (Canon)
on Jan 27, 2021 at 23:17 UTC ( #11127549=note: print w/replies, xml ) Need Help??


in reply to Re^2: Index or iterate - your choice
in thread Index or iterate - your choice

I did consider including that, but by providing a tied array, you're kind of encouraging end users to treat it as any old array.

So they might not consider that doing something like:

foreach my $item ( reverse @array ) { ... }

Is going to impact performance way more than they might expect.

If it's exposed as an iterator, then it encourages them to access items in a one-at-a-time sequential fashion. They still can slurp it all into an array, but they can't blame you when that eats up all their memory.

Not saying it's never a good idea, but situations where it is aren't going to be that common.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://11127549]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others perusing the Monastery: (6)
As of 2021-10-26 10:00 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    My first memorable Perl project was:







    Results (90 votes). Check out past polls.

    Notices?