I was recently playing around with decorators and experimenting with
defining a function's signature dynamically at runtime, and came across the
builtins.function class constructor (more easily accessible through the
types.FunctionType alias). I quickly realized, however, that even though
the constructor has a parameter (argdefs) that is used to specify default
values for the resulting function's positional arguments, there is no
corresponding parameter for keyword-only argument defaults. This seems like
a glaring omission, especially considering the fact that argdefs takes a
tuple that is directly assigned (unmodified) to the __defaults__ attribute.
I can't find any obvious reason why there shouldn't be a similar "kwdefs"
parameter that takes a dict and assigns it to __kwdefaults__. I downloaded
the cpython repo, made this change myself as proof-of-concept, and compiled
it, and it appears to work fine. This brings me to two questions:

1. Is there a reason for this disparity that I'm not seeing (e.g. breaking
some other feature), or is it just an oversight?
2. If I wanted to submit this as an actual language change, would I need to
write a full PEP or is it small enough that it could go to the issue
tracker? (Note that the documentation says this constructor can vary
between implementations, so the change would only apply to cpython if that
matters.)

Also, if this is the wrong place to ask this, please feel free to set me
straight; I'm completely new to this whole process, so any help on where to
start would be appreciated.
_______________________________________________
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/3ETG4HAKR2WQWAKAFCHU4UMC5X37OHKZ/
Code of Conduct: http://python.org/psf/codeofconduct/

Reply via email to