Re: sub signatures coming

2014-02-25 Thread Will Crawford
On 25 February 2014 03:45, Paul Makepeace pa...@paulm.com wrote: Finally. But don't believe the python/perl comparison troll, as python, for once, actually outguns perl on a character chomping basis, sub pairwise_sum ($arg1, $arg2) { return map { $arg1-[$_] + $arg2-[$_] } 0 .. $#$arg1;

Re: sub signatures coming

2014-02-25 Thread James Laver
On 25 Feb 2014, at 03:45, Paul Makepeace pa...@paulm.com wrote: On Mon, Feb 24, 2014 at 2:04 PM, Steve Mynott steve.myn...@gmail.com wrote: http://perltricks.com/article/72/2014/2/24/Perl-levels-up-with-native-subroutine-signatures Finally. But don't believe the python/perl comparison troll,

Re: sub signatures coming

2014-02-25 Thread James Laver
On 25 Feb 2014, at 11:18, James Laver james.la...@gmail.com wrote: But I probably already have List::MoreUtils imported (because Perl). sub pairwise_sum ($a1, $a2) { zip @$a1, @$a2; } And lets ignore the fact that the perl version that was used in the article was buggy. If $arg2 is

Re: sub signatures coming

2014-02-25 Thread Matt Lawrence
On 25/02/14 11:18, James Laver wrote: On 25 Feb 2014, at 03:45, Paul Makepeace pa...@paulm.com wrote: On Mon, Feb 24, 2014 at 2:04 PM, Steve Mynott steve.myn...@gmail.com wrote: http://perltricks.com/article/72/2014/2/24/Perl-levels-up-with-native-subroutine-signatures Finally. But don't

Re: sub signatures coming

2014-02-25 Thread Ruud H.G. van Tol
On 2014-02-25 04:45, Paul Makepeace wrote: On Mon, Feb 24, 2014 at 2:04 PM, Steve Mynott steve.myn...@gmail.com wrote: http://perltricks.com/article/72/2014/2/24/Perl-levels-up-with-native-subroutine-signatures Finally. But don't believe the python/perl comparison troll, as python, for

Re: consolidate regexes

2014-02-25 Thread Jérôme Étévé
What about Regexp::Assemble ? J. On 25 February 2014 12:49, Dirk Koopman d...@tobit.co.uk wrote: I am looking at an application where some incoming string needs to be compared to many (certainly 10s, probably 100s but not 1000s) regexes. This being a message passing application, speed is more

Re: consolidate regexes

2014-02-25 Thread Smylers
Dirk Koopman writes: ... some incoming string needs to be compared to many (certainly 10s, probably 100s but not 1000s) regexes. ... speed is more important than it might otherwise be. Aaron Crane mentions a couple of modules which might help (in explaining his module which does something

Re: consolidate regexes

2014-02-25 Thread Alex Balhatchet
Hey Dirk, The search time you're after is Trie. http://en.wikipedia.org/wiki/Trie https://metacpan.org/search?q=trie The POD of Dan Kogai's Regexp::Trie lists some alternatives and the description compares them a little. https://metacpan.org/pod/Regexp::Trie#DESCRIPTION

Re: consolidate regexes

2014-02-25 Thread Alex Balhatchet
The search time you're after is Trie. I mean search term... - Alex

Re: consolidate regexes

2014-02-25 Thread Jérôme Étévé
If you're looking to find the matches of a large number of strings in a body of text, there's also https://metacpan.org/pod/Text::Scan . AFAIK, it's very fast, as it's a C implementation of http://en.wikipedia.org/wiki/Aho%E2%80%93Corasick_string_matching_algorithm It doesn't do regexes though,

Re: sub signatures coming

2014-02-25 Thread James Laver
On 25 Feb 2014, at 11:31, Matt Lawrence matt.lawre...@virgin.net wrote: On 25/02/14 11:18, James Laver wrote: But I probably already have List::MoreUtils imported (because Perl). sub pairwise_sum ($a1, $a2) { zip @$a1, @$a2; } And lets ignore the fact that the perl version that was

Re: consolidate regexes

2014-02-25 Thread Aaron Crane
Alex Balhatchet ka...@slackwise.net wrote: The POD of Dan Kogai's Regexp::Trie lists some alternatives and the description compares them a little. The regexes generated by Regexp::Trie will almost certainly be slower to execute than the regex you'd get with the naive approach: my $pattern =

Re: consolidate regexes

2014-02-25 Thread Alex Balhatchet
On 25 February 2014 14:59, Aaron Crane p...@aaroncrane.co.uk wrote: That's because, thanks to demerphq++, Perl 5.10 and above have a built-in trie optimisation which is defeated by the cleverness of the Regexp::Trie regexes. To take the example from the Regexp::Trie documentation: Oh my,

Re: consolidate regexes

2014-02-25 Thread Nicholas Clark
On Tue, Feb 25, 2014 at 03:25:54PM +, Alex Balhatchet wrote: On 25 February 2014 14:59, Aaron Crane p...@aaroncrane.co.uk wrote: That's because, thanks to demerphq++, Perl 5.10 and above have a built-in trie optimisation which is defeated by the cleverness of the Regexp::Trie regexes.

Re: sub signatures coming

2014-02-25 Thread Paul Makepeace
On Feb 25, 2014 7:16 AM, James Laver james.la...@gmail.com wrote: On 25 Feb 2014, at 11:31, Matt Lawrence matt.lawre...@virgin.net wrote: On 25/02/14 11:18, James Laver wrote: But I probably already have List::MoreUtils imported (because Perl). sub pairwise_sum ($a1, $a2) { zip

Re: consolidate regexes

2014-02-25 Thread Abigail
On Tue, Feb 25, 2014 at 03:59:21PM +, Nicholas Clark wrote: On Tue, Feb 25, 2014 at 03:25:54PM +, Alex Balhatchet wrote: On 25 February 2014 14:59, Aaron Crane p...@aaroncrane.co.uk wrote: That's because, thanks to demerphq++, Perl 5.10 and above have a built-in trie optimisation

Re: consolidate regexes

2014-02-25 Thread James Laver
On 25 Feb 2014, at 16:45, Nicholas Clark n...@ccl4.org wrote: Vendor supplied perl is going to be slower than one you compile yourself. Or at least, it won't be faster. Historically this wasn’t always the case*. When ubuntu first got going, their packages were a little faster to load than

Re: sub signatures coming

2014-02-25 Thread Yitzchak Scott-Thoennes
The blog post modified the original from returning an arrayref to returning a list. Restoring the arrayref, I'd: use Algorithm::Loops 'MapCarE'; use List::Util 'sum'; sub pairwise_sum { [ MapCarE { sum @_ } @_ ] } (note that the only improvement offered by 5.19.9 would be to arbitrarily limit

Re: sub signatures coming

2014-02-25 Thread Kent Fredric
On 26 February 2014 03:59, James Laver james.la...@gmail.com wrote: Ah yes. I’d just woken up. sub pairwise_sum($a2,$a2) { map {shift($_)+shift($_)} (zip @$a1, @$a2); } ... I think you need that book we're writing more than you need to write it ;) -- Kent