Revisit Mutable Default Arguments

Good question. In summary:

Whenever the Python interpreter sees an expression of the form deferred x, it would treat it as if it were Deferred(lambda: x) thereby creating a “deferred expression object”.

When the Python interpreter processes a function call, and is filling in default values for unspecified parameters, it would check if each parameter is an instance of the type Deferred, and if so, it would unbox it first.

The dataclass function would alter its code generation so that whenever it sees a default value of type Deferred, it would treat it as if it were a default factory having callable equal to the deferred value object’s boxed callable.