This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

classification
Title: In re's examples the example with recursion doesn't work
Type: Stage: resolved
Components: Documentation, Regular Expressions Versions: Python 3.2
process
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: docs@python Nosy List: docs@python, ezio.melotti, mrabarnett, py.user, python-dev
Priority: normal Keywords:

Created on 2012-03-17 00:48 by py.user, last changed 2022-04-11 14:57 by admin. This issue is now closed.

Messages (4)
msg156112 - (view) Author: py.user (py.user) * Date: 2012-03-17 00:48
http://docs.python.org/py3k/library/re.html#avoiding-recursion

>>> import sys
>>> sys.getrecursionlimit()
1000
>>> import re
>>> s = 'Begin ' + 1000*'a very long string ' + 'end'
>>> re.match('Begin (\w| )*? end', s).end()
19009
>>>
msg156126 - (view) Author: Matthew Barnett (mrabarnett) * (Python triager) Date: 2012-03-17 02:41
As far as I can tell, back in 2003, changes were made to replace the recursive scheme which used stack allocation with a non-recursive scheme which used heap allocation in order to the improve the behaviour.

To me it looks like an oversight and that the example should have been removed at the time, but unfortunately was retained and just updated in subsequent releases to refer to the Python version ("python3.2" in this case).
msg156169 - (view) Author: Roundup Robot (python-dev) (Python triager) Date: 2012-03-17 16:26
New changeset 8172d7dce0ed by Georg Brandl in branch '3.2':
Closes #14342: remove out-of-date section about avoiding recursion errors.
http://hg.python.org/cpython/rev/8172d7dce0ed
msg156171 - (view) Author: Roundup Robot (python-dev) (Python triager) Date: 2012-03-17 16:27
New changeset 276f79e4b215 by Georg Brandl in branch '2.7':
Closes #14342: remove out-of-date section about avoiding recursion errors.
http://hg.python.org/cpython/rev/276f79e4b215
History
Date User Action Args
2022-04-11 14:57:28adminsetgithub: 58550
2012-03-17 16:27:47python-devsetmessages: + msg156171
2012-03-17 16:26:40python-devsetstatus: open -> closed

nosy: + python-dev
messages: + msg156169

resolution: fixed
stage: resolved
2012-03-17 02:41:19mrabarnettsetmessages: + msg156126
2012-03-17 00:48:27py.usercreate