Re: [Python-Dev] Return from generators in Python 3.2

2010-08-27 Thread Greg Ewing
Ron Adam wrote: I wonder if "yield from" may run into pythons stack limit? My current implementation wouldn't, because nested yield-froms don't result in nested activations of Python frames. But... if __name__ == "__main__": print(factoral(1)) # < extra zero too! But if I add

Re: [Python-Dev] Return from generators in Python 3.2

2010-08-26 Thread Ron Adam
On 08/26/2010 07:25 PM, Guido van Rossum wrote: That's not my experience. I wrote a trampoline myself (not released yet), and found that I had to write a lot more code to deal with the absence of yield-from than to deal with returns. In my framework, users write 'raise Return(value)' where Retu

Re: [Python-Dev] Return from generators in Python 3.2

2010-08-26 Thread Bob Ippolito
On Fri, Aug 27, 2010 at 8:25 AM, Guido van Rossum wrote: > On Thu, Aug 26, 2010 at 5:05 PM, Yury Selivanov wrote: >> On 2010-08-26, at 8:04 PM, Greg Ewing wrote: >>> Even with your proposal, you'd still have to use a 'creepy >>> abstraction' every time one of your coroutines calls another. >>> Th

Re: [Python-Dev] Return from generators in Python 3.2

2010-08-26 Thread Yury Selivanov
On 2010-08-26, at 1:10 PM, Eric Smith wrote: > On 8/26/10 12:48 PM, Yury Selivanov wrote: >> On 2010-08-26, at 12:20 PM, Scott Dial wrote: >>> BTW, attaching patches to >>> emails on this list is generally the best way to have few look at your >>> patch. :-p >> >> Hm, my mailing client clearly in

Re: [Python-Dev] Return from generators in Python 3.2

2010-08-26 Thread Yury Selivanov
On 2010-08-26, at 8:25 PM, Guido van Rossum wrote: > On Thu, Aug 26, 2010 at 5:05 PM, Yury Selivanov wrote: >> On 2010-08-26, at 8:04 PM, Greg Ewing wrote: >>> Even with your proposal, you'd still have to use a 'creepy >>> abstraction' every time one of your coroutines calls another. >>> That's w

Re: [Python-Dev] Return from generators in Python 3.2

2010-08-26 Thread Eric Smith
On 8/26/10 12:48 PM, Yury Selivanov wrote: On 2010-08-26, at 12:20 PM, Scott Dial wrote: BTW, attaching patches to emails on this list is generally the best way to have few look at your patch. :-p Hm, my mailing client clearly indicates that the patch has been attached and sent. In any case,

Re: [Python-Dev] Return from generators in Python 3.2

2010-08-26 Thread Guido van Rossum
On Thu, Aug 26, 2010 at 5:05 PM, Yury Selivanov wrote: > On 2010-08-26, at 8:04 PM, Greg Ewing wrote: >> Even with your proposal, you'd still have to use a 'creepy >> abstraction' every time one of your coroutines calls another. >> That's why PEP 380 deals with 'more than just return'. > > Nope.  

Re: [Python-Dev] Return from generators in Python 3.2

2010-08-26 Thread Yury Selivanov
On 2010-08-26, at 8:04 PM, Greg Ewing wrote: > Even with your proposal, you'd still have to use a 'creepy > abstraction' every time one of your coroutines calls another. > That's why PEP 380 deals with 'more than just return'. Nope. In almost any coroutine framework you have a scheduler or trampo

Re: [Python-Dev] Return from generators in Python 3.2

2010-08-26 Thread Greg Ewing
Yury Selivanov wrote: However, as I outlined in the first message, this was intended to prevent this kind of mistakes: ... def test(): ... for i in range(10): ... yield i ... return 10 Which will certainly happen, especially with people new to python. That very problem was co

Re: [Python-Dev] Return from generators in Python 3.2

2010-08-26 Thread Nick Coghlan
On Fri, Aug 27, 2010 at 8:31 AM, Yury Selivanov wrote: > All this proposal is suggesting is to replace SyntaxError with > GeneratorReturn (or StopIteration).  I'd classify is as a minor change > than some special refactoring that may fall under the moratorium.  Correct > me if I'm wrong. It's eit

Re: [Python-Dev] Return from generators in Python 3.2

2010-08-26 Thread Yury Selivanov
On 2010-08-26, at 6:11 PM, Nick Coghlan wrote: > On Fri, Aug 27, 2010 at 1:00 AM, Yury Selivanov wrote: >> In the above, GeneratorReturn error will be propagated stopping the program >> execution. >> Strictly speaking, the proposed change is just alters the current Python >> behaviour, >> makin

Re: [Python-Dev] Return from generators in Python 3.2

2010-08-26 Thread Nick Coghlan
On Fri, Aug 27, 2010 at 1:00 AM, Yury Selivanov wrote: > In the above, GeneratorReturn error will be propagated stopping the program > execution. > Strictly speaking, the proposed change is just alters the current Python > behaviour, > making the 'return value' statement raise catchable error (i

Re: [Python-Dev] Return from generators in Python 3.2

2010-08-26 Thread Yury Selivanov
On 2010-08-26, at 12:20 PM, Scott Dial wrote: > On 8/26/2010 11:00 AM, Yury Selivanov wrote: >> If we decide to postpone this feature till Python 3.3, than we'll push it >> all back >> The change is tiny, but it means really a lot. > > AFAICT, this change was the most controversial part of PEP 3

Re: [Python-Dev] Return from generators in Python 3.2

2010-08-26 Thread Scott Dial
On 8/26/2010 11:00 AM, Yury Selivanov wrote: > If we decide to postpone this feature till Python 3.3, than we'll push it all > back > The change is tiny, but it means really a lot. AFAICT, this change was the most controversial part of PEP 380. > PS I'm attaching a patch to the letter; it's far

[Python-Dev] Return from generators in Python 3.2

2010-08-26 Thread Yury Selivanov
Hello, I want to bring up a "forbidden" topic, however, I believe I have some strong points. There are many ways of doing asynchronous programming in Python. Multiprocessing, Threads, Greenlets, Deferred Object (Callbacks) and Coroutines. The latter is quite a new approach, but it gets mor