On Tue, Jan 19, 2021 at 10:08 AM Mark Shannon <m...@hotpy.org> wrote:

>
>
> On 19/01/2021 5:48 pm, Guido van Rossum wrote:
> > I'm not clear on how you plan to implement this in CPython.
> >
> > I can totally see that if a Python function calls another Python
> > function, you can avoid the C stack frame and hence you can have as many
> > Python call levels as you want.
> >
> > However, there are many scenarios where a Python function calls a C
> > function (e.g. `filter()`, or `dict.__setitem__()`) and that C function
> > at some point calls a Python function (e.g. the `__hash__()` method of
> > the key, or even the `__del__()` method of the value being replaced).
> > Then that Python function can recursively do a similar thing.
>
> Indeed, that is the second case below, where a Python __add__
> function recursively performs addition. Most likely, the C stack will
> get exhausted before the recursion limit is hit, so you'll get a
> StackOverflow exception.
>
> >
> > Are you proposing to also support that kind of thing to go on for a
> > million levels of C stack frames?
>
> No, most likely 10k to 20k calls before a StackOverflow exception.
>

Okay, that helps my understanding of the proposal. So StackOverflow really
means "C stack overflow"? And the plan seems to be

- no intervening C frame for Python-to-Python calls
- fix all C code to explicitly check for stack overflow (even in `__del__`)
- decouple RecursionError (Python) from StackOverflow (C)

If you can pull that off I am all for it.

-- 
--Guido van Rossum (python.org/~guido)
*Pronouns: he/him **(why is my pronoun here?)*
<http://feministing.com/2015/02/03/how-using-they-as-a-singular-pronoun-can-change-the-world/>
_______________________________________________
Python-Dev mailing list -- python-dev@python.org
To unsubscribe send an email to python-dev-le...@python.org
https://mail.python.org/mailman3/lists/python-dev.python.org/
Message archived at 
https://mail.python.org/archives/list/python-dev@python.org/message/5K5VZZS7J7ZSDLKEC6NKGSMLOPL3S5C2/
Code of Conduct: http://python.org/psf/codeofconduct/

Reply via email to