PEP 709: one behavior change that was missed in the PEP

This post PEP example for me is much cleaner and obvious, that comprehension should have access to class scope

2 Likes

Sorry. as I wrote in my earlier replies on the thread - restoring the Python 2 behavior for comprehension is a great win for this pep. I think there are a exhaustive checks as can be done that this change won’t break any reasonable existing code - (in the “un-reasonable” we can put code meant to behave in an intuitive way, like the example above where a class body function was named “set”. ).

Sorry - if things are not clear enough by this point, then maybe the PEP should be postponed so that we can think scopes better for 3.13 - otherwise, this “small side effect” seems, by all approaches, to be a big win.

The SC has approved the approach of restoring the previous class scoping behavior for 3.12 (PEP 709, for the third and (hopefully) final time · Issue #192 · python/steering-council · GitHub). I think that’s the right call: we get the performance benefits from PEP 709 now without changes to scoping behavior, and we have time to think about intentionally changing the behavior for 3.13. Note that the feature freeze for Python 3.12 is in less than a week.

If there is strong support for changing the scoping behavior in 3.13, we should put together a PEP that proposes that change. If the PEP is approved, it shouldn’t be difficult to implement, but we should think hard about whether we really want the change. (Note that we are not restoring the Python 2 behavior. Iteration variables are still isolated.)

14 Likes