Is the regular expression module written in C or Python?

Ulli Stein mennosimons at
Sat Oct 5 16:51:00 CEST 2002

Martin v. Loewis wrote:

> "Zhitenev Alexander" <zhitenev at> writes:
>> In Python prior to 2.0 RE engine was PCRE - Perl compatible regular
>> expressions, written in pure C, all Python code was only binding to it.
> Actually, pcre was only added in  1.5; 1.4 (and I believe back to 1.2)
> only had Tatu Ylonen's regexpr.c, wrapped by regex.
> Regards,
> Martin

When will the +? or *? operator be fully supported in the re module?

Try this in the python interpreter
>>> import re
>>> re.findall("\[(.*?)\]", "["+"x"*10000+"]")
Traceback (most recent call last):
  File "<stdin>", line 1, in ?
  File "/usr/lib/python2.2/", line 166, in findall
    return _compile(pattern, 0).findall(string)
RuntimeError: maximum recursion limit exceeded
>>> re.findall("\[(.*?)\]", "["+"x"*9996+"]")

If the part which .*? will match exceeds 9996 bytes python throws the above 
exception. Having this bug, re renders itself unusable.


More information about the Python-list mailing list