News for hackers. Stuff that matters.
Re:Strict Python function parameters by georgyo on Sunday January 23, 2022 @11:56AM (#30047741)
The PEP seems entirely focused on bound checking and performing functions on variables in the function definition.

I'm not sure it handles the use case op is talking about.

IE def foo(bar=list()): # this creates a mutable list shard by all calls of the function. Very unlikely something you want.

Maybe the pep would allow for def foo(bar=>list()):

But the pep does not address this use case at all

Re:Strict Python function parameters by meowface on Sunday January 23, 2022 @12:10PM (#30047895)
Even though the PEP doesn't explicitly mention mutable default arguments, I'm pretty sure it's intended for this use case, as well. It should address this issue.

>Function parameters can have default values which are calculated during function definition and saved. This proposal introduces a new form of argument default, defined by an expression to be evaluated at function call time.