Efficient String Lookup?

Helmut Jarausch jarausch at skynet.be
Sun Oct 17 12:17:39 CEST 2004


Chris S. wrote:
> I have a number of strings, containing wildcards (e.g. 'abc#e#' where # 
> is anything), which I want to match with a test string (e.g 'abcdef'). 
> What would be the best way for me to store my strings so lookup is as 
> fast as possible?

A  very flexible and fast tool is mxTextTools
http://www.egenix.com/files/python/mxTextTools.html
see also
http://simpleparse.sourceforge.net
which contains a more recent (non recursive) version of the pattern 
matching machine
It's faster then regexp (at least sometimes) but much more flexible
Each pattern is stored as (high level) "assembler" for a pattern 
matching machine written in C. A Pattern is just a Python tuple
which can be stored (pickled)

-- 
Helmut Jarausch

Lehrstuhl fuer Numerische Mathematik
RWTH - Aachen University
D 52056 Aachen, Germany



More information about the Python-list mailing list