note
BrowserUk
From PerlOP:
<blockquote><i>In the current implementation, no temporary array is created when the range operator is used as the expression in foreach loops, but older versions of Perl might burn
a lot of memory when you write something like this:</i></blockquote>
<p>Many of my efficiency habits formed back in 5.6/5.8 days, and I've never seen the need to change them.
<P>One problem is that optimisation only kicks in in certain circumstances -- and I don't remember if I ever knew what they exactly were. I have a sneaking suspicion that in 32-bit perls, anything over 2**31 may have caused a list, but I haven't used a 32-bit perl for a decade, so I cannot check.
<p>One example that bit me was the iterator moving outside the range of integers:<code>
1 for 1e200 .. 1e200+1e6;;
[Range iterator outside integer range at (eval 10) line 1, <STDIN> line 2.
</code>
<p>Easy enough to re-write that one, but not so much if the numbers come from outside or are generated.
<p>The [while]/[until] loop approach handles anything 64-bit floats can, and (from) memory, is usually faster than postfix [for] even for integers; though that could have changed a lot since I last benchmarked it.
<p>I like to program in a consistent way -- where it doesn't compromise performance to do so -- and tend to stick with patterns once I've established ones that work.
<P>Eg. I still use '<:raw' as a matter of course, even though things changed and it was deprecated when they re-vamped PerlIO, and it was demonstrated that some other combination of pushing, popping and/or applying of layers was apparently faster. The whole thing just got too complex to remember and too convoluted to test.
<P>The whole PerlIO thing was something of a debacle IMO; a vast amount of effort and change for something that 95% of Perl users have never used :(
<div class="pmsig"><div class="pmsig-171588">
<hr />
<font size=1 >
<div>With the rise and rise of 'Social' network sites: 'Computers are making people easier to use everyday'</div>
<div>Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.</div>
<div>"Science is about questioning the status quo. Questioning authority". [http://www.theregister.co.uk/2016/11/02/complexity_in_it/|The enemy of (IT) success is complexity.]</div>
<div>In the absence of evidence, opinion is indistinguishable from prejudice.
<span>[https://www.theregister.co.uk/2017/04/10/mark_shuttleworth_says_some_free_software_contributors_are_deeply_anti_social/|Suck that fhit]</span> </div>
</font>
</div></div>
1214667
1214787