[Python-Dev] PEP 558: Defined semantics for locals()
Guido van Rossum
guido at python.org
Sat May 25 17:26:35 EDT 2019
That's a good fine point that the PEP could call out, but just adding
"dynamic" in front of "snapshot" everywhere doesn't tell me any of that.
Given that the code calling locals() must of necessity live in the same
function body (except for the special case of trace functions), I don't
think that what you describe here is too worrisome a scenario.
On Sat, May 25, 2019 at 2:09 PM Nathaniel Smith <njs at pobox.com> wrote:
> On Sat, May 25, 2019, 07:38 Guido van Rossum <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).
--Guido van Rossum (python.org/~guido)
*Pronouns: he/him/his **(why is my pronoun here?)*
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the Python-Dev