Why re.match()?

pdpi pdpinheiro at gmail.com
Tue Jul 7 15:37:02 CEST 2009


On Jul 2, 4:49 am, kj <no.em... at please.post> wrote:
> In <Xns9C3BCA27ABC36duncanbo... at 127.0.0.1> Duncan Booth <duncan.bo... at invalid.invalid> writes:
>
> >So, for example:
> >>>> re.compile("c").match("abcdef", 2)
> ><_sre.SRE_Match object at 0x0000000002C09B90>
> >>>> re.compile("^c").search("abcdef", 2)
>
> I find this unconvincing; with re.search alone one could simply
> do:
>
> >>> re.compile("^c").search("abcdef"[2:])

given large enough values of "abcdef", you just allocated several megs
for no good reason, when re.compile("c").match("abcdef", 2) would
process "abcdef" in-place.



More information about the Python-list mailing list