[Python-Dev] [PEP 558] thinking through locals() semantics
greg.ewing at canterbury.ac.nz
Wed May 29 19:09:42 EDT 2019
Nick Coghlan wrote:
> If there was a compelling use case for letting "a = 1; exec(src);
> print(a)" print something other than "1" at function scope, then I'd
> be more amenable to the idea of the associated compatibility break and
> potential performance regression in other implementations.
> However, there isn't any such use case - if there were, we wouldn't
> have deliberately changed the semantics from the old Python 2 ones to
> the current Python 3 ones in PEP 3100 .
I get the impression that was done because everyone involved
thought it wasn't worth the ugliness of maintaining all the
fast/locals swapping stuff, not because of any principle that
the current behaviour is right or better in any way.
Given a locals proxy object, it would be much easier to support
the old behaviour (which seems obvious and correct to me) without
eval or exec having to be anything special.
More information about the Python-Dev