[Python-Dev] SRE recursion removed

Gustavo Niemeyer niemeyer at conectiva.com
Sun Oct 19 10:06:39 EDT 2003


> However, I'm concerned that track is completely lost as to how SRE
> works -

You may have lost it. I haven't.

> is it or is it not the case that the current implementation
> which is in CVS is recursive, with arbitrary deep nesting? If it is

It is *NOT* the case.

Do the following test: set USE_RECURSION_LIMIT to *2*, and run the
tests.

There's a single case of single recursion, that's why it can't be 1:
when SRE_COUNT() is called from the main loop, and then it calls
SRE_MATCH() again. OTOH, this second call of SRE_MATCH() will *never*
recurse again, unless there's a serious bug in the expression compiler
(which is not the case right now). To give an example of when this
single recursion happens, suppose the following expression: "[ab]*".

> not recursive anymore (which the subject suggests), then why is the is
> the 'level' argument still in? Can we or can we not remove the ad-hoc
> determination of USE_RECURSION_LIMIT?

USE_RECURSION_LIMIT is a friend of USE_RECURSION. We have already
discussed this in other messages.

> > Yeah.. I can clean it. let's please wait a little bit to
> > see the new code working?
> 
> Certainly. However, I was hoping that we have better means of finding
> out whether the code still does what it is supposed to do than
> testing. Perhaps that is an illusion.

I'm shocked. Do you really belive that I've done all the changes and
past fixes in SRE without knowing how it works? I thought my
credibility was a little higher.

-- 
Gustavo Niemeyer
http://niemeyer.net



More information about the Python-Dev mailing list