User talk:SqrtNegInf: Difference between revisions

(→‎Zumkeller twiddles: new section)
 
Line 93:
 
The reasoning behind the separate test statements, and [&&] rather than [and] is that the way I had it, the tests are high precedence and short-circuiting; as soon as one fails it stops testing and moves on to the next maybe. With the low precedence conditionals, it will test ''every'' branch whether or not one has already failed. It will reach the same conclusion in the long run but waste a lot more processing cycles getting there. Does it matter in the long run? Meh, probably not, but I purposely structured it that way for a real reason. C-style loops are still (marginally) faster than range iteration. Sub sum() is still (marginally) faster than method .sum (or at least it was last time I checked, which admittedly has been some time.) For the first two parts it probably doesn't make a discernible difference. I was optimizing to try to make the third part not so tedious. (Same reason I used ntheory rather than built-ins.) The other stylistic twiddles? Yeah, that was me being lazy. Cheers. --[[User:Thundergnat|Thundergnat]] ([[User talk:Thundergnat|talk]]) 10:36, 30 May 2022 (UTC)
 
: I confess that initially I did only the most cursory of speed tests before committing the new version (hmmm, that seems fine, click). I do have a tendency to care more about how the code ''reads'' than how it ''runs'', but what you say is true so I took it as an excuse (barely needed) to go down the rabbit hole and do more complete testing on Zumkeller, plus further tests on other kinds of operations. To a degree that surprised me, the take-away was that generally the details of how a given line or block of code is written–in the context of a larger program–barely matter, the timing differences ending up within the error bars. There are counter-examples where it does matter, and since Raku is not the speediest of languages to begin with we all need to be mindful of that (he said, looking in the mirror).
 
: Overall, I take this as great news. It means that when writing Raku programmers can indulge their particular coding peculiarities / OCD (or whatever DSM-IV code applies in ones' individual case) and mostly turns out fine, now and probably in the future as well, which is when most of the code is going to be seen and/or run (100-year language and all that). But if I went too far: tack back! --[[User:SqrtNegInf|SqrtNegInf]] ([[User talk:SqrtNegInf|talk]]) 18:15, 9 June 2022 (UTC)
2,392

edits