saving / restoring the stack?

sismex01 at sismex01 at
Mon Mar 17 21:48:38 CET 2003

> From: Clark C. Evans [mailto:cce at]
> Sent: Monday, March 17, 2003 2:36 PM
> Hello.  I have a strange request.  I was wondering if it is
> possible to "save" the current stack; unwind down say 3 
> levels, do some stuff down there, and then resume execution
> back up where I was before?  It is possible to have two
> saved stacks?
> Clark

This sounds very much like a generator.

Do you know where and how many times you're going to have
to suspend execution?  You could program the function (which
needs to be suspended) as a generator, and simply call it's
"next()" method to resume execution.

You could also take a look at Stackless Python, which enables
the creation of "tasklets", which are functions that can be
suspended, resumed, or launched as lightweight threads.
It's a very cool piece of technology.  I don't have a link
handy, but you can very easily find it googling for
"stackless python".




More information about the Python-list mailing list