On Wed, Jan 20, 2016 at 2:05 PM Yury Selivanov <yselivanov.ml@gmail.com> wrote:
On 2016-01-20 1:37 AM, Nick Coghlan wrote:
> On 20 January 2016 at 10:38, Chris Angelico<rosuav@gmail.com>  wrote:
> With that spelling:
>
>      def f(*, len=len):
>           ...
>
> Would become:
>
>      def f():
>          sharedlocal len=len

FWIW I strongly believe that this feature (at least the
"len=len"-like optimizations) should be implemented as an
optimization in the interpreter.

We already have "nonlocal" and "global".  Having a third
modifier (such as sharedlocal, static, etc) will only
introduce confusion and make Python less comprehensible.

If the purpose is to improve speed, it certainly feels like an interpreter optimization. The other thread about adding ``ma_version`` to dicts might be useful for quickening the global variable lookup.

If the purpose is to store the current global value, it might be reasonable to add a language feature to make that more explicit. Beginners often mistakenly think that default values are evaluated and assigned at call-time instead of def-time. However, adding a new, more explicit language feature wouldn't eliminate the current confusion. Instead we'd have two ways to do it.