[Python-Dev] PEP 340: Deterministic Finalisation (new PEP draft, either a competitor or update to PEP 340)

Ron Adam rrr at ronadam.com
Sun May 8 00:42:51 CEST 2005

Josiah Carlson wrote:

 > You should know why that can't work.  If I pass a list, is a list an
 > iterator?  No, but it should neither be created nor destroyed before or
 > after.
 > The discussion has been had in regards to why re-using 'for' is a
 > non-starter; re-read the 200+ messages in the thread.
 >  - Josiah

I agree, re-using or extending 'for' doesn't seem like a good idea to me.

I wonder how much effect adding, 'for-next' and the 'StopIteration' 
exception check as proposed in PEP340, will have on 'for''s performance.

And why this isn't just as good:

         for value in iterator:
     except StopIteration:

Is one extra line that bad?

I think a completely separate looping or non-looping construct would be 
better for the finalization issue, and maybe can work with class's with 
__exit__ as well as generators.

Having it loop has the advantage of making it break out in a better 
behaved way.  So may be Nicks PEP, would work better with a different 

Hint: 'do'


More information about the Python-Dev mailing list