Message297503
| Author |
ncoghlan |
| Recipients |
Mark.Shannon, arigo, belopolsky, benjamin.peterson, ncoghlan, njs, vstinner, xdegaye, xgdomingo, yselivanov |
| Date |
2017年07月02日.02:52:59 |
| SpamBayes Score |
-1.0 |
| Marked as misclassified |
Yes |
| Message-id |
<1498963981.07.0.0534225847653.issue30744@psf.upfronthosting.co.za> |
| In-reply-to |
| Content |
As per the discussion in issue #17960, I'm going to put together a short PEP about this topic for Python 3.7 that will better specify the expected behaviour of locals() and frame.f_locals.
That will be a combination of making the status quo official, proposing some changes, and asking Guido for a design decision.
Documenting the status quo: make the current behaviour at module scope, class scope, and the corresponding behaviours of exec and eval officially part of the status quo
Proposing a change: replacing the current LocalsToFast approach with a custom write-through proxy type that updates the locals array and nonlocal cell variables immediately whenever frame.f_locals is modified (this is the part that should fix the bug reported in this issue)
Requesting a design decision: whether locals() at function(/generator/coroutine) scope should return:
- a direct reference to the write-through proxy
- a live read-only dict-proxy (ala class __dict__ attributes)
- a point-in-time snapshot (i.e. copying the namespace) |
|