The implementation starts here:
https://github.com/python/cpython/blob/ecb035cd14c11521276343397151929a94018a22/Objects/funcobject.c#L499

The argument clinic input specifying the signature is a few lines above.
Clinic's output is here:
https://github.com/python/cpython/blob/master/Objects/clinic/funcobject.c.h

I suspect that the omission is just an oversight. You should probably just
open a bug on bugs.python.org. If you feel like contributing code, not just
bug reports, try working on a pull request! (See the devguide:
https://devguide.python.org/)

Good luck!


On Fri, Oct 18, 2019 at 6:33 AM Gus Wiedey <guswie...@gmail.com> wrote:

> 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/
>


-- 
--Guido van Rossum (python.org/~guido)
*Pronouns: he/him **(why is my pronoun here?)*
<http://feministing.com/2015/02/03/how-using-they-as-a-singular-pronoun-can-change-the-world/>
_______________________________________________
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/XY7AN457ZMJUL4UH7YR6NQ5L7LJSHV2S/
Code of Conduct: http://python.org/psf/codeofconduct/

Reply via email to