[Python-Dev] trashcan and PR#7

Christian Tismer tismer@tismer.com
Wed, 12 Apr 2000 21:03:33 +0200


Jeremy Hylton wrote:
> 
> >>>>> "CT" == Christian Tismer <tismer@tismer.com> writes:
> 
>   CT> Vladimir Marangozov wrote:
>   >>  While I'm at it, maybe the same recursion control logic could be
>   >> used to remedy (most probably in PyObject_Compare) PR#7:
>   >> "comparisons of recursive objects" reported by David Asher?
> 
>   CT> Hey, what a good idea.
> 
>   CT> You know what's happening? We are moving towards tail recursion.
>   CT> If we do this everywhere, Python converges towards Stackless
>   CT> Python.
> 
> It doesn't seem like tail-recursion is the issue, rather we need to
> define some rules about when to end the recursion.  If I understand
> what is being suggest, it is to create a worklist of subobjects to
> compare instead of making recursive calls to compare.  This change
> would turn the core dump into an infinite loop; I guess that's an
> improvement, but not much of one.

Well, I actually didn't read PR#7 before replying.
Thought it was about comparing deeply nested structures.

What about this?
For one, we do an improved comparison, which is of course
towards tail recursion, since we push part of the work
after the "return".
Second, we can guess the number of actually existing objects,
and limit the number of comparisons by this.
If we need more comparisons than we have objects,
then we raise an exception.

Might still take some time, but a bit less than infinite.

ciao - chris   (sub-cantor-set-minded)

-- 
Christian Tismer             :^)   <mailto:tismer@appliedbiometrics.com>
Applied Biometrics GmbH      :     Have a break! Take a ride on Python's
Kaunstr. 26                  :    *Starship* http://starship.python.net
14163 Berlin                 :     PGP key -> http://wwwkeys.pgp.net
PGP Fingerprint       E182 71C7 1A9D 66E9 9D15  D3CC D4D7 93E2 1FAE F6DF
     where do you want to jump today?   http://www.stackless.com