[Python-Dev] PEP 550 v4

Stefan Krah stefan at bytereef.org
Thu Sep 7 10:42:21 EDT 2017

On Thu, Sep 07, 2017 at 09:41:10AM -0400, Elvis Pranskevichus wrote:
> threading.local(), the isolation mechanism, is *implicit*.  
> decimal.localcontext() is an  *explicit* resource manager that relies on 
> threading.local() magic.  PEP 550 simply provides a threading.local() 
> alternative that works in tasks and generators.  That's it!

If there only were a name that would make it explicit, like TaskLocalStorage. ;)

Seriously, the problem with 'context' is that it is:

  a) A predefined set of state values like in the Decimal (I think also
     the OpenSSL) context.

     But such a context is put inside another context (the ExecutionContext).

  b) A theoretical concept from typed Lambda calculus (in the context
     'gamma' the variable 'v' has type 't').

     But this concept would be associated with lexical scope and would
     extend to functions (not only tasks and generators).

  c) ``man 3 setcontext``. A replacement for setjmp/longjmp.  Somewhat
     related in that it could be used to implement coroutines.

  d) The .NET flowery language.  I do did not fully understand what the
     .NET ExecutionContext and its 2881 implicit flow rules are.


Stefan Krah

More information about the Python-Dev mailing list