On Thu, Jul 29, 2021 at 4:52 PM Nick Coghlan <ncogh...@gmail.com> wrote: > > On Fri, 30 Jul 2021, 6:05 am Mark Shannon, <m...@hotpy.org> wrote: >> >> Hi Nick, >> >> Our discussion on PEP 558 got me thinking >> "What is the simplest thing that would work?". >> >> This is what I came up (in the form of a draft PEP): >> https://github.com/markshannon/peps/blob/pep-locals/pep-06xx.rst >> >> It doesn't have O(1) len(f_locals), and it does break >> `PyEval_GetLocals()` but I think the that is a small price to pay for >> simplicity and consistency. > > > I don't think it is OK to break PyEval_GetLocals() when we really don't need > to, > and the proposal also discards all the feedback that I received on earlier > iterations of PEP 558. (I particularly recommend reading Nathaniel's analysis > of why returning the proxy from locals() would be more likely to cause bugs > in existing code than it would be to eliminate any).
Heh, I was actually just re-reading PEP 558 and going to ask you to include more details to justify the complexity, as compared to something like Mark's latest proposal here -- I'd totally forgotten I wrote that old post :-). So that was a timely reminder! Looking at the references in the PEP, is this the writeup you're talking about? https://mail.python.org/pipermail/python-dev/2019-May/157738.html The conclusion there is: > I'm leaning towards saying that on net, [snapshot] beats [PEP-minus-tracing]: > it's dramatically simpler, and the backwards incompatibilities that we've > found so far seem pretty minor, on par with what we do in every point release. (In fact, in 3/4 of the cases I looked at, [snapshot] is actually what users seemed to trying to use in the first place.) > > For [proxy] versus [snapshot], a lot depends on what we think of changing the > semantics of exec(). [proxy] is definitely more consistent and elegant, and > if we could go back in time I think it's what we'd have done from the start. Its compatibility is maybe a bit worse than [snapshot] on non-exec() cases, but this seems pretty minor overall (it often doesn't matter, and if it does just write dict(locals()) instead of locals(), like you would in non-function scope). But the change in exec() semantics is an actual language change, even though it may not affect much real code, so that's what stands out for me. I *think* (please correct me if I'm wrong) that what that calls [PEP-minus-tracing] is now corresponds to the current PEP draft, and [proxy] corresponds to Mark's draft at the beginning of this thread? -n -- Nathaniel J. Smith -- https://vorpus.org _______________________________________________ Python-Dev mailing list -- python-dev@python.org To unsubscribe send an email to python-dev-le...@python.org https://mail.python.org/mailman3/lists/python-dev.python.org/ Message archived at https://mail.python.org/archives/list/python-dev@python.org/message/TB6FZXVO3LQFFVCKAN7OTAJ427HY67TF/ Code of Conduct: http://python.org/psf/codeofconduct/