Beefy Boxes and Bandwidth Generously Provided by pair Networks
Welcome to the Monastery
 
PerlMonks  

Re: New regex trick...

by japhy (Canon)
on Jul 22, 2002 at 20:18 UTC ( [id://184219]=note: print w/replies, xml ) Need Help??


in reply to New regex trick...

If this patch doesn't go through (and I can see reasons why it wouldn't, but I'd like it to go through), the same functionality can be achieved by my new module, Regexp::Keep. It's not on CPAN yet, but it's an XS module that does two things:
  1. filters regexes for the \K escape sequence, and turns them into (?{Regexp::Keep::KEEP})...
  2. and defines an XS function, KEEP(), that does what \K is supposed to do
Of course, constant-overloading is nasty, so I hope my patch is received well.

_____________________________________________________
Jeff[japhy]Pinyan: Perl, regex, and perl hacker, who'd like a job (NYC-area)
s++=END;++y(;-P)}y js++=;shajsj<++y(p-q)}?print:??;

Replies are listed 'Best First'.
Re: Re: New regex trick...
by mischief (Hermit) on Jul 24, 2002 at 13:00 UTC
    Can you post some benchmarks for the module? Or are the ones you posted above from the module (I'm assuming not).
      Here's the code:
      use Benchmark 'cmpthese'; use Regexp::Keep; my $s = "abc.def.ghi.jkl"; cmpthese(-5, { japhy => sub { (my $x = $s) =~ s/.*\K\..*// }, old => sub { (my $x = $s) =~ s/(.*)\..*/$1/ }, });
      In 5.6.1:
      old = 40280.54/s japhy = 74338.79/s
      And with 5.8.0 (using the module, NOT my patch):
      old = 58188.18/s japhy = 102409.25/s
      So there's an appreciable speed-up.

      _____________________________________________________
      Jeff[japhy]Pinyan: Perl, regex, and perl hacker, who'd like a job (NYC-area)
      s++=END;++y(;-P)}y js++=;shajsj<++y(p-q)}?print:??;

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://184219]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others having an uproarious good time at the Monastery: (1)
As of 2024-04-24 16:06 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found