Nick Coghlan <ncogh...@gmail.com> added the comment:

Thinking about the interaction between this idea and 
https://bugs.python.org/issue30744 made me realise that there's a subtlety here 
that would probably need to be spelled out more clearly in the docs for 
__closure__ than it is for __code__: any changes made to a function object 
(whether it's a synchronous function, a generator, or a coroutine) will only 
affect *future* function invocations, as execution frames capture references to 
both the code object and all the closure cells when they're created.

(Thought prompted by asking myself "What would happen to existing 
generator-iterators if you rebound the closure on the generator function?". The 
answer is "Nothing", but I figure if I had to think about it, that answer 
likely isn't going to be obvious to folks that are less familiar with how the 
eval loop works in practice)

----------

_______________________________________
Python tracker <rep...@bugs.python.org>
<https://bugs.python.org/issue14369>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to