PEP 667: add 709 impact, other tweaks #3196
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
A few proposed updates to PEP 667. Namely:
frame.f_locals
be a proxy in module or class scopes. In particular, makinglocals()
always return a new snapshot (rather than the true persistent locals dict) in module or class scopes would be too large a back-compat break, I think, since people may be currently relying on assignment tolocals()
in those scopes. Instead I think we can simply preserve the current (3.12) behavior thatlocals()
returns a new snapshot dict in module/class scope only when inside an inlined comprehension. This PEP makes that behavior consistent with howlocals()
works inside functions, so in effect it preserves the fiction that a comprehension is a function, even though it is inlined.f_locals
that are not local variables.📚 Documentation preview 📚: https://pep-previews--3196.org.readthedocs.build/