[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: A Problem with Python's 'yield'

On Tue, 2003-05-27 at 11:15, Eric Kidd wrote:
> I'm going to pick on Python here, but only because the example code will
> be short and sweet. :-) I believe several other implementations of
> generators have the same problem.

I expect you'll find this limitation in every language that is
imlemented using a C stack and recursion for function calls.  Python's
generator are sometimes called "simple generators" because they are
simple to implement.  There is only a single function call frame that
needs to be kept around after a generator yields a value.

Python would need to keep multiple C stack frames alive across yields. 
The current implementation isn't amenable to that.  The Jython
developers tell us they'd have trouble, too.