Re: [Python-ideas] Raise StopIteration with same value on subsequent `next`s

2017-12-11 Thread Franklin? Lee
On Mon, Dec 11, 2017 at 6:44 PM, Yury Selivanov wrote: > On Mon, Dec 11, 2017 at 6:21 PM, Franklin? Lee > wrote: >> What about hanging onto just the value, and creating new StopIteration >> instances instead of raising the same one again? > > Doesn't really matter, as we're still prolonging the l

Re: [Python-ideas] Raise StopIteration with same value on subsequent `next`s

2017-12-11 Thread Yury Selivanov
On Mon, Dec 11, 2017 at 6:21 PM, Franklin? Lee wrote: > What about hanging onto just the value, and creating new StopIteration > instances instead of raising the same one again? Doesn't really matter, as we're still prolonging the lifespan of the returned object. To me the current behaviour of g

Re: [Python-ideas] Raise StopIteration with same value on subsequent `next`s

2017-12-11 Thread Franklin? Lee
What about hanging onto just the value, and creating new StopIteration instances instead of raising the same one again? On Mon, Dec 11, 2017 at 3:06 PM, Guido van Rossum wrote: > IIRC we considered this when we designed this (PEP 380) and decided that > hanging on to the exception object longer t

Re: [Python-ideas] Raise StopIteration with same value on subsequent `next`s

2017-12-11 Thread Guido van Rossum
IIRC we considered this when we designed this (PEP 380) and decided that hanging on to the exception object longer than necessary was not in our best interest. On Mon, Dec 11, 2017 at 1:10 AM, Franklin? Lee < leewangzhong+pyt...@gmail.com> wrote: > Consider the following code, which creates a gen

[Python-ideas] Raise StopIteration with same value on subsequent `next`s

2017-12-11 Thread Franklin? Lee
Consider the following code, which creates a generator that immediately returns 1, and then catches the StopIteration twice. def generatorfunction(): if False: yield return 1 def get_return(gen): try: next(gen) except StopIteration as e: