[Python-Dev] PEP 550 v3 (original) (raw)

Yury Selivanov yselivanov.ml at gmail.com
Mon Aug 21 15:53:02 EDT 2017


On Sat, Aug 19, 2017 at 4:17 AM, Nick Coghlan <ncoghlan at gmail.com> wrote: [..]

* Generator's .send() and .throw() methods are modified as follows (in pseudo-C):: if gen.logicalcontext is not NULL: tstate = PyThreadStateGet() tstate.executioncontext.push(gen.logicalcontext) try: # Perform the actual Generator.send() or # Generator.throw() call. return gen.send(...) finally: gen.logicalcontext = tstate.executioncontext.pop() else: # Perform the actual Generator.send() or # Generator.throw() call. return gen.send(...) I think this pseudo-code expansion includes a few holdovers from the original visibly-immutable API design. Given the changes since then, I think this would be clearer if the first branch used sys.runwithlogicalcontext(), since the logical context references at the Python layer now behave like shared mutable objects, and the apparent immutability of sys.runwithexecutioncontext() comes from injecting a fresh logical context every time.

This is a good idea, I like it! It will indeed simplify the explanation.

Yury



More information about the Python-Dev mailing list