idiom for RE matching
roger.miller at nova-sol.com
Thu Jul 19 23:36:22 CEST 2007
On Jul 18, 6:52 pm, Gordon Airporte <JHoo... at fbi.gov> wrote:
> I've also been assuming that using the re functions that create match
> objects is slower/heavier than dealing with the simple list returned by
> findall(). I've profiled it and these matches are the biggest part of
> the running time of the program, so I really would rather not use
> anything slower.
My guess would be that searching for more matches after finding the
first would be more expensive than creating a match object. But that
would probably depend on the nature of your data and REs, so you need
to test it both ways if you are concerned about performance.
It would be nice if findall() had an optional parameter to limit the
number of matches, similar to the maxsplit parameter of string.split().
More information about the Python-list