Regex anomaly

Andrew Durdin adurdin at gmail.com
Tue Jan 3 06:06:23 EST 2006


On 3 Jan 2006 02:20:52 -0800, Sam Pointon <free.condiments at gmail.com> wrote:
> Would this particular inconsistency be candidate for change in Py3k?
> Seems to me the pos and endpos arguments are redundant with slicing,

Being able to specify the start and end indices for a search is
important when working with very large strings (multimegabyte) --
where slicing would create a copy, specifying pos and endpos allows
for memory-efficient searching in limited areas of a string.

> and the re.match function would benefit from having the same arguments
> as pattern.match.

Not at all; the flags need to be specified when the regex is compiled,
as they affect the compiled representation (finite state automaton I
expect) of the regex. If the flags were given in pattern.match(), then
there'd be no performance benefit gained from precompiling the regex.

Andrew



More information about the Python-list mailing list