On Sat, Aug 19, 2017 at 4:17 AM, Nick Coghlan <ncogh...@gmail.com> wrote: [..] >> >> * Generator's ``.send()`` and ``.throw()`` methods are modified as >> follows (in pseudo-C):: >> >> if gen.__logical_context__ is not NULL: >> tstate = PyThreadState_Get() >> >> tstate.execution_context.push(gen.__logical_context__) >> >> try: >> # Perform the actual `Generator.send()` or >> # `Generator.throw()` call. >> return gen.send(...) >> finally: >> gen.__logical_context__ = tstate.execution_context.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.run_with_logical_context(), since the logical > context references at the Python layer now behave like shared mutable > objects, and the apparent immutability of > sys.run_with_execution_context() comes from injecting a fresh logical > context every time.
This is a good idea, I like it! It will indeed simplify the explanation. Yury _______________________________________________ Python-Dev mailing list Python-Dev@python.org https://mail.python.org/mailman/listinfo/python-dev Unsubscribe: https://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com