> On 27 May 2021, at 14:18, Steven D'Aprano <st...@pearwood.info> wrote: > > On Thu, May 27, 2021 at 07:56:16AM -0000, Shreyan Avigyan wrote: > >> Lot of programming languages have something known as static variable >> storage in *functions* not *classes*. Static variable storage means a >> variable limited to a function yet the data it points to persists >> until the end of the program. > > +1 on this idea. > > One common use for function defaults is to optimize function lookups to > local variables instead of global or builtins: > > def func(arg, len=len): > # now len is a fast local lookup instead of a slow name lookup
That’s a CPython performance hack, and “static” would just introduce a different performance hack. IIRC there has been work in recent versions of CPython to reduce the need for that hack by caching values in the VM. Ronald — Twitter / micro.blog: @ronaldoussoren Blog: https://blog.ronaldoussoren.net/
_______________________________________________ Python-ideas mailing list -- python-ideas@python.org To unsubscribe send an email to python-ideas-le...@python.org https://mail.python.org/mailman3/lists/python-ideas.python.org/ Message archived at https://mail.python.org/archives/list/python-ideas@python.org/message/7R6MCO2UKF5DZXVGSEZEC55RCOAHF2ZW/ Code of Conduct: http://python.org/psf/codeofconduct/