[Python-ideas] Keyword only argument on function call

Chris Angelico rosuav at gmail.com
Tue Sep 11 08:02:15 EDT 2018


On Tue, Sep 11, 2018 at 9:34 PM, Steven D'Aprano <steve at pearwood.info> wrote:
> I think that __params__ as an implicitly created local variable is
> just barely justifiable, if you don't care about slowing down all
> function calls for the benefit of a tiny number of them. But exposing
> that information as an externally visible attribute of the function
> object is probably unworkable and unnecessary.

Rather than slowing down ALL function calls, you could slow down only
those that use it. The interpreter could notice the use of the name
__params__ inside a function and go "oh, then I need to include the
bytecode to create that". It'd probably need to be made a keyword, or
at least unassignable, to ensure that you never try to close over the
__params__ of another function, or declare "global __params__", or
anything silly like that. I'm still -1 on adding it, though.

ChrisA


More information about the Python-ideas mailing list