Python Regex Question
David
wizzardx at gmail.com
Fri Sep 21 15:53:15 EDT 2007
> re.search(expr, string) compiles and searches every time. This can
> potentially be more expensive in calculating power. especially if you
> have to use the expression a lot of times.
The re module-level helper functions cache expressions and their
compiled form in a dict. They are only compiled once. The main
overhead would be for repeated dict lookups.
See sre.py (included from re.py) for more details. /usr/lib/python2.4/sre.py
More information about the Python-list
mailing list