Beefy Boxes and Bandwidth Generously Provided by pair Networks RobOMonk
Perl-Sensitive Sunglasses
 
PerlMonks  

Re^3: counting backward (optimize foreach reverse low .. high

by LanX (Abbot)
on Mar 02, 2013 at 15:24 UTC ( #1021427=note: print w/ replies, xml ) Need Help??


in reply to Re^2: counting backward (optimize foreach reverse low .. high
in thread counting backward

AFAIK for( @f ) is optimized to act like an iterator without expanding and caching the list.

But in for(reverse @f ) there is no for-context which helps reverse to act differently.

I'm to lazy for benchmarks (we had them before), but this was surely not fixed in 5.8.8

Cheers Rolf


Comment on Re^3: counting backward (optimize foreach reverse low .. high
Select or Download Code
Re^4: counting backward (optimize foreach reverse low .. high
by Anonymous Monk on Mar 02, 2013 at 15:30 UTC
    You're wrong

        Maybe it's optimized for reversing arrays but not for reversing ranges:

        Kind of why I suggested optimizing it for ranges also

        Nice try , but you're still wrong

        You sais But in for(reverse @f ) there is no for-context which helps reverse to act differently.

        That has nothing to do with ranges, and its still wrong

Re^4: counting backward (optimize foreach reverse low .. high
by dave_the_m (Parson) on Mar 02, 2013 at 15:35 UTC
    for(reverse @f) has been optimised not to expand the array since 5.10.0.

    Dave.

      Maybe it's optimized for reversing arrays but not for reversing ranges:

      I had to stop the second version because the swapping started to freeze my system:

      lanx@nc10-ubuntu:~$ perl -e'for my $i ( 0 .. 1e8 ) { $x*=-1; $x+=$i }; +print "$x\n"' 50000000 lanx@nc10-ubuntu:~$ perl -e'for my $i ( reverse 0 .. 1e8 ) { $x*=-1; $ +x+=$i };print "$x\n"' ^C^C^C lanx@nc10-ubuntu:~$ perl -version This is perl, v5.10.0 built for i486-linux-gnu-thread-multi ...

      Reversing ranges was what BUK did, but AnoMonk replied with a reference to a fix for reversing arrays!

      Cheers Rolf

        Reversing ranges was what BUK did, but AnoMonk replied with a reference to a fix for reversing arrays!

        As a suggestion to fix range operator

        Maybe it's optimized for reversing arrays but not for reversing ranges:
        But the post of yours which I replied to explicitly showed @a as an example, not a range. I never claimed ranges were optimised, while you implied that arrays weren't.

        Dave.

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others browsing the Monastery: (7)
As of 2014-04-21 09:10 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    April first is:







    Results (492 votes), past polls