G'day Dean,

"List::Util::pairmap would be an existing solution very similar to the new feature. It also seems to run quite quickly (but I can't compare it to for_list since I don't have a new-enough perl)."

No problem. I have v5.36.0 installed. I added your code to the OP benchmark code.

Mine starts as follows. Refer to "perl5360delta: use v5.36" for why I removed the strict and warnings pragmata.

#!/usr/bin/env perl use v5.36; use List::Util qw /pairs pairvalues pairmap/;

I then added:

I ran the benchmark five times. All results were pretty much the same; here's a median set:

2500050000 2500050000 2500050000 2500050000 2500050000 2500050000 2500050000 2500050000 2500050000 Rate a_pairs_alias a_pairs h_each h_by_key h_for_list +h_vals a_pair_vals a_pairmap a_for_list a_pairs_alias 48.8/s -- -4% -67% -73% -83% + -90% -90% -92% -94% a_pairs 51.0/s 4% -- -66% -71% -82% + -90% -90% -91% -94% h_each 150/s 207% 193% -- -16% -47% + -69% -71% -74% -82% h_by_key 178/s 265% 249% 19% -- -37% + -64% -65% -69% -78% h_for_list 284/s 482% 457% 90% 59% -- + -42% -45% -51% -66% h_vals 490/s 903% 860% 227% 175% 72% + -- -5% -16% -41% a_pair_vals 513/s 951% 906% 243% 188% 81% + 5% -- -12% -38% a_pairmap 582/s 1091% 1041% 289% 226% 105% + 19% 13% -- -30% a_for_list 827/s 1594% 1521% 453% 364% 191% + 69% 61% 42% --

In all runs, a_pairmap was second fastest; and, h_by_key was faster than h_each (which differs from the OP results).

My environment:

$ perl -v | head -2 | tail -1 This is perl 5, version 36, subversion 0 (v5.36.0) built for cygwin-th +read-multi $ uname -a CYGWIN_NT-10.0 titan 3.2.0(0.340/5/3) 2021-03-29 08:42 x86_64 Cygwin

— Ken


In reply to Re^2: perl 5.36 and the for_list feature - a simple speed comparison by kcott
in thread perl 5.36 and the for_list feature - a simple speed comparison by swl

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.