codehaus


[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Python-Dev] [SPAM?] Re: PEP 558: Defined semantics for locals()


On 5/25/19 5:09 PM, Nathaniel Smith wrote:
> On Sat, May 25, 2019, 07:38 Guido van Rossum <guido at python.org
> <mailto:guido at python.org>> wrote:
>
>     This looks great.
>
>     I only have two nits with the text.
>
>     First, why is the snapshot called a "dynamic snapshot"? What
>     exactly is dynamic about it?
>
>
> It's dynamic in that it can spontaneously change when certain other
> events happen. For example, imagine this code runs at function scope:
>
> # take a snapshot
> a = locals()
>
> # it's a snapshot, so it doesn't include the new variable
> assert "a" not in a
>
> # take another snapshot
> b = locals()
>
> # now our first "snapshot" has changed
> assert "a" in a
>
> Overall I'm happy with the PEP, but I'm still a bit uneasy about
> whether we've gotten the details of this "dynamicity" exactly right,
> esp. since the PEP promotes them from implementation detail to
> language features. There are a lot of complicated tradeoffs so I'm
> working on a longer response that tries to lay out all the options and
> hopefully convince myself (and everyone else).
>
> -n
To me that is a static snapshot of a dynamic environment, not a dynamic
snapshot. The snapshot you get at THAT moment in time won't change, as
time progresses, so that snapshot itself isn't dynamic. Calling
something a 'dynamic snapshot' could be take to imply that the snapshot
itself is dynamic, and thus changes at that environment changes (and you
could pass that snapshot to some other place, and they could get a view
of things just like you would see it there,

-- 
Richard Damon