On Tue, Aug 21, 2018 at 12:21 AM, Steven D'Aprano <st...@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 _______________________________________________ Python-ideas mailing list Python-ideas@python.org https://mail.python.org/mailman/listinfo/python-ideas Code of Conduct: http://python.org/psf/codeofconduct/