3 ms·
Right. You have to be very careful to always yield to another function that uses yield. It can become very hairy with deep call chains. The limitation is tha
by aliguori 16y ago
Right. You have to be very careful to always yield to another function that uses yield. It can become very hairy with deep call chains.
The limitation is that Python has to be statically prove that a function is really a generator for yield to work and they do this by forcing there to be a yield in the actual function.
- jamwt 16y agoYep, this was a big part of why I eventually abandoned generators in diesel in favor of a greenlet-based approach. http://github.com/jamwt/diesel/commit/2fc64f9d50bc6f9a5cfff0a33d06a9a5e1ef4ed1 http://github.com/jamwt/diesel/commit/2fc64f9d50bc6f9a5cfff0... I'd worked my way through all the problems having to do with simulating a generator-based "stack" and it was not pretty--exception handling in particular with these "fake stacks" was hard to make behave the usual pythonic way. I wasn't eager to give up on a generators, but I had to eventually concede that the practical quality of the project was more important than the founding idea. Everything has been faster, easier to program, and more stable since giving up on generators and moving to the greenlet library. At bump, we just launched version 2.0 of our app, running our backends 100% on diesel2/greenlets: http://mashable.com/2010/07/26/bump-2-0/ http://mashable.com/2010/07/26/bump-2-0/