I was pleasantly surprised today to discover that any, all (and also or, etc.) now short-circuit properly.

With one of previous versions (it was the same with 2.085, which I don't have already):

Loaded PDL v2.084 pdl> $x = zeroes byte, 1e9 pdl> $a = copy $x; set $a, 0, 1 pdl> $z = copy $x; set $z, -1, 1 pdl> help vars PDL variables in package main:: Name Type Dimension Flow State Mem ---------------------------------------------------------------- $a Byte D [1000000000] P 953.67MB $x Byte D [1000000000] P 953.67MB $z Byte D [1000000000] P 953.67MB pdl> with_time { print $x-> any, ' ' } for 1..3 0 1567.51 ms 0 1498.09 ms 0 1505.89 ms pdl> with_time { print $a-> any, ' ' } for 1..3 1 970.624 ms 1 941.319 ms 1 940.539 ms pdl> with_time { print $z-> any, ' ' } for 1..3 1 1489.67 ms 1 1510.22 ms 1 1468.07 ms pdl>

"$a" case is somewhat faster, but shouldn't it be instant instead of almost a second? Now let's see with current release:

Loaded PDL v2.088 pdl> $x = zeroes byte, 1e9 pdl> $a = copy $x; set $a, 0, 1 pdl> $z = copy $x; set $z, -1, 1 pdl> help vars PDL variables in package main:: Name Type Dimension Flow State Mem ---------------------------------------------------------------- $a Byte D [1000000000] P 953.67MB $x Byte D [1000000000] P 953.67MB $z Byte D [1000000000] P 953.67MB pdl> with_time { print $x-> any, ' ' } for 1..3 0 783.335 ms 0 749.517 ms 0 756.531 ms pdl> with_time { print $a-> any, ' ' } for 1..3 1 0.103 ms 1 0.091 ms 1 0.092 ms pdl> with_time { print $z-> any, ' ' } for 1..3 1 748.246 ms 1 741.717 ms 1 739.352 ms pdl>

Not only $x and $z cases are twice as fast, but the $a case short-circuits indeed. I don't see this improvement mentioned in what's new (is it somewhat vague "PP add loop(n=start:end:inc) idiom to stop not at end and have non-1 inc"?); changes like this should be heralded in city squares, no less :-). Very good work!


In reply to Re: PDL 2.087 released and a summary of a ~year of PDL by Anonymous Monk
in thread PDL 2.087 released and a summary of a ~year of PDL by zmughal

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.