On May 31, 2004, at 5:25 PM, Martin v. Löwis wrote:
Bob Ippolito wrote:
I'm believe that map and filter are non-recursive
Can you point me to the code that demonstrates this? Looking at Stackless' src/Python/bltinmodule.c:builtin_map, I see
for (i = 0; ; ++i) { ... value = PyEval_CallObject(func, alist); ... PyList_SetItem(result, i, value) ... }
which looks recursive to me.
Ok, then I am mistaken. I thought I had seen a commit message that said it was made non-recursive. Either way, it's possible to write a non-recursive version of map or anything else, it's just a bit of work.
I am not sure about unicode encode/decode. I don't think it's very common to do a tasklet switch in the middle of a unicode encode or decode, though :)
I thought Stackless was not only about tasklet switching, but also about running without stack... Wouldn't it perform the "hard" switching if the stack is running too deep?
I don't think so, because the C stack should never run too deep, since most code that is going to recurse (from the python-view) will do it non-recursively (from the C-view).
Py-func1() -> C-func1() -> Py-func2() -> switch to new tasklet Py-func3() -> C-func2() -> throw exception() I don't see how it could cause problems unless this is valid: Py_Func1 -> CPlusPlus_ExceptionCatcher -> Py_Func2 -> CPlusPlus_ExceptionThrower -> throws exception()
It crashes in the process of throwing the exception - not because it finds no exception handler. It crashes because the internal data structures have been corrupted.
I should have better made this example:
Py-func1() -> C-func1() -> Py-func2() -> switch to new tasklet Py-func3() -> Exception-Catcher -> C-func2() -> throw exception()
If that *is* valid, how the heck does Py_Func2 get cleaned up? I have to admit that I'm not very familiar with C++'s implementation of exceptions.
Throwing exceptions through Python functions is not supported, indeed. However, I was trying to point out that the entire exception handling mechanism gets corrupted, even if there are valid handlers on the stack.
I don't think that the entire exception handling mechanism gets corrupted. Each tasklet should always have a consistent view of the C stack. Anyway, I don't think we need to discuss it any further unless someone writes a failing test... and if that is indeed the case, then the discussion should be taken to the stackless list. -bob