
Tim Peters wrote:
[Christian Tismer]
... Yup. With a little counting, it was easy to survive:
def main(): global a a=2 thing (5) a=a-1 if a: saved.throw (0)
Did "a" really need to be global here? I hope you see the same behavior without the "global a"; e.g., this Scheme:
(Hüstel) Actually, I inserted the "global" later. It worked as well with a local variable, but I didn't understand it. Still don't :-)
Or does brute-force frame-copying cause the continuation to set "a" back to 2 each time?
No, it doesn't. Behavior is exactly the same with or without global. I'm not sure wether this is a bug or a feature. I *think* 'a' as a local has a slot in the frame, so it's actually a different 'a' living in both copies. But this would not have worked. Can it be that before a function call, the interpreter turns its locals into a dict, using fast_to_locals? That would explain it. This is not what I think it should be! Locals need to be copied.
and needs a much better interface.
Ya, like screw 'em and use threads <wink>.
Never liked threads. These fibers are so neat since they don't need threads, no locking, and they are available on systems without threads.
But finally I'm quite happy that it worked so smoothly after just a couple of hours (well, about six :)
Yup! Playing with Python internals is a treat.
to-be-continued-ly y'rs - tim
throw(42) - chris -- Christian Tismer :^) <mailto:tismer@appliedbiometrics.com> Applied Biometrics GmbH : Have a break! Take a ride on Python's Kaiserin-Augusta-Allee 101 : *Starship* http://starship.python.net 10553 Berlin : PGP key -> http://wwwkeys.pgp.net PGP Fingerprint E182 71C7 1A9D 66E9 9D15 D3CC D4D7 93E2 1FAE F6DF we're tired of banana software - shipped green, ripens at home