[Python-Dev] PEP 550 v3
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.__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
More information about the Python-Dev
mailing list