Efficient String Lookup?

Chris S. chrisks at NOSPAM.udel.edu
Sun Oct 17 00:51:37 CEST 2004

Diez B. Roggisch wrote:

> That might be faster, if the string.find operation uses something else than
> simple brute force linear searching - but I don't know enough about the
> internals of python's string implementation to give an definite answer
> here.
> But to be honest: I don't think regexps are easy to beat, unless your
> usecase is modeled in a way that makes it prone to other approaches.

The problem is, I want to find all patterns that match my test string, 
so even with re I'd still have to search through every pattern, which is 
what I'm trying to avoid. Something like a trie might be better, but 
they don't seem very efficient when implemented in Python.

More information about the Python-list mailing list