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

Yury Selivanov yselivanov.ml at gmail.com
Wed Aug 30 10:36:20 EDT 2017


On Wed, Aug 30, 2017 at 9:44 AM, Yury Selivanov <yselivanov.ml at gmail.com> wrote: [..]

FYI, I've been sketching an alternative solution that addresses these kinds of things. I've been hesitant to post about it, partly because of the PEP550-based workarounds that Nick, Nathaniel, Yury etc. have been describing, and partly because that might be a major distraction from other useful discussions, especially because I wasn't completely sure yet about whether my approach has some fatal flaw compared to PEP 550 ;). We'll never know until you post it. Go ahead.

The only alternative design that I considered for PEP 550 and ultimately rejected was to have a the following thread-specific mapping:

{ var1: [stack of values for var1], var2: [stack of values for var2] }

So the idea is that when we set a value for the variable in some frame, we push it to its stack. When the frame is done, we pop it. This is a classic approach (called Shallow Binding) to implement dynamic scope. The fatal flow that made me to reject this approach was the CM protocol (enter). Specifically, context managers need to be able to control values in outer frames, and this is where this approach becomes super messy.

Yury



More information about the Python-Dev mailing list