convert list of strings to set of regexes; convert list of strings to trie

François Pinard pinard at iro.umontreal.ca
Tue Jul 20 18:27:10 CEST 2004


[Klaus Neuner]
> [François Pinard]

> > By the way, the regexp compiler in Python library already
> > turns, at least logically, `(blaa)|(blab)|(raaa)|(rabb)' into
> > `(bla(a|b))|(ra(aa|bb))' -- disregarding of course how groups
> > are being saved by parentheses.  So, you may also peek in this
> > direction.

> What do you mean exactly by "logically"? That Python translates (1) to
> something (logically equivalent to) (2) before matching it?  Does this
> mean that (1) (taken as normal regex) is always exactly as fast as (2)
> (taken as normal regex)?

This is what I understand, yes: it is not worth optimising regexps the
above way ourselves (as we sometimes do for Emacs Lisp regexps, say),
before giving them to the Python regexp compiler.

-- 
François Pinard   http://www.iro.umontreal.ca/~pinard



More information about the Python-list mailing list