On 19 August 2017 at 06:33, Yury Selivanov <yselivanov...@gmail.com> wrote: > Hi, > > This is a third iteration of the PEP. > > There was some really good feedback on python-ideas and > the discussion thread became hard to follow again, so I decided to > update the PEP only three days after I published the previous > version. > > Summary of the changes can be found in the "Version History" > section: https://www.python.org/dev/peps/pep-0550/#version-history > > There are a few open questions left, namely the terminology > and design of ContextKey API. On the former topic, I'm quite > happy with the latest version: Execution Context, Logical > Context, and Context Key.
Nice, I quite like this version of the naming scheme and the core design in general. While Guido has a point using the same noun for two different things being somewhat confusing, I think the parallel here is the one between the local scope and the lexical (nonlocal) scope for variable names - just as your lexical scope is a nested stack of local scopes in outer functions, your execution context is your current logical context plus a nested stack of outer logical contexts. > Generator Object Modifications > ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ > > To achieve this, we make a small set of modifications to the > generator object: > > * New ``__logical_context__`` attribute. This attribute is readable > and writable for Python code. > > * When a generator object is instantiated its ``__logical_context__`` > is initialized with an empty ``LogicalContext``. > > * 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. Also +1 to the new design considerations questions that explicitly postpones consideration of any of my "What about..."" questions from python-ideas to future PEPs. Cheers, Nick. -- Nick Coghlan | ncogh...@gmail.com | Brisbane, Australia _______________________________________________ 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