Does Python optimize regexes?

Peter Otten __peter__ at web.de
Tue Jun 29 09:18:02 EDT 2004


Peter Otten wrote:

> Python puts the compiled regular expressions into a cache. The relevant

By the way, re.compile() uses that cache, too:

>>> import re
>>> r1 = re.compile("abc")
>>> r2 = re.compile("abc")
>>> r1 is r2
True

Peter





More information about the Python-list mailing list