union in Python
Duncan Booth
duncan at NOSPAMrcp.co.uk
Tue Aug 19 04:17:57 EDT 2003
bokr at oz.net (Bengt Richter) wrote in news:bhrsuj$mdv$0 at 216.39.172.122:
> But I don't see any reason why the performances couldn't be made to
> match.
For searching short strings there probably isn't any advantage to using
Boyer-Moore, and for short search strings the advantage is probably quite
small. I think you would need to spend some time working out just where the
breakpoints are that make it worth switching from a plain search to one
that skips ahead.
The regular expression search may still win, since regular expressions,
even if not precompiled, are cached. That means that if you perform the
regex search millions of times, the setup cost is only incurred once.
String searches don't have this advantage, and it seems unlikely to be
worth the effort of caching arguments passed to string.find!
--
Duncan Booth duncan at rcp.co.uk
int month(char *p){return(124864/((p[0]+p[1]-p[2]&0x1f)+1)%12)["\5\x8\3"
"\6\7\xb\1\x9\xa\2\0\4"];} // Who said my code was obscure?
More information about the Python-list
mailing list