[Python-ideas] Jump to function as an an alternative to call function

Chris Angelico rosuav at gmail.com
Mon Aug 20 10:37:11 EDT 2018


On Tue, Aug 21, 2018 at 12:21 AM, Steven D'Aprano <steve at pearwood.info> wrote:
> On Sun, Aug 19, 2018 at 06:18:56PM +0300, Kirill Balunov wrote:
>
> [...]
>> > > e) It leaves a room for a future changes (In fact, in some situations I
>> > > would like to have this possibility).
>
> [Chris]
>> > Related to (e) is that there is room for other implementations to
>> > permit changes to locals(), and furthermore, a fully-compliant Python
>> > implementation may use an actual dictionary for locals, and simply
>> > return that. (That CPython doesn't is an implementation detail for the
>> > sake of performance.) Requiring that it be a proxy would impose
>> > unnecessary cost on the implementation, without benefiting any
>> > compliant use.
>
> I would like to see CPython locals() return a mapping object which
> raises a warning when you mutate it.

That, I can get behind. Requiring it to be a proxy would IMO be a bad
idea; but the warning here would be a CPython implementation detail.
OTOH, warnings are easy to miss. But on the gripping hand, if more of
Python and CPython raised warnings when odd things or
implementation-specific things were done, it would encourage people to
develop with warnings active.

ChrisA


More information about the Python-ideas mailing list