Stackless Python, eventual merge?

Martin v. Löwis loewis at informatik.hu-berlin.de
Wed Sep 18 03:58:56 EDT 2002


Greg Ewing <see_reply_address at something.invalid> writes:

> Last I heard, Christian was moving pieces of the C
> stack while there could be pointers to it in use.

Yes, that's how stackless works, and that cannot change.

> That's definitely dangerous, as he discovered when
> it broke Tk.

What is the danger? A program crashes? It is dangerous to cross a
street at rush hour; sitting in front of a computer is rarely
dangerous.

Stackless adds a few limitations as to what C extensions can do. If
those restrictions are followed, it won't crash.

> I'd be very nervous about using Stackless until
> it stops doing that.

Why is that? Those crashes can only happen if you use the stackless
modules (and only if you use them with a stackless-unsafe extension).
If you don't import stackless, no stack is copied.

> Seems to me it could be fixed by just copying the
> C stack as a whole, instead of piecemeal.

Then it won't be stackless - one application is that the recursion
limit is only constrained by the heap size, not by the stack size.
Also, task switching becomes very expensive when copying the entire
thread. Finally, you *still* can get it to break: some extension
module might preserve the address of a local variable in global state,
but then the entire stack is copied away.

Regards,
Martin



More information about the Python-list mailing list