On 27 May 2021, at 14:18, Steven D'Aprano <steve@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/