[Python-Dev] Updated PEP 362 (Function Signature Object)

Nick Coghlan ncoghlan at gmail.com
Wed Jun 6 23:25:16 CEST 2012


On Jun 7, 2012 3:11 AM, "Steven D&apos;Aprano" <steve at pearwood.info> wrote:
>
> Larry Hastings wrote:
>
>>> [...]
>>> "Changes to the Signature object, or to any of its data members,
>>> do not affect the function itself."
>>>
>>> which leaves the possibility that __signature__ may no longer match the
actual argument spec, for some reason. If you remove getfullargspec, people
will have to reinvent it to deal with such cases.
>>
>>
>> There's no reason why they should disagree.  The "some reason" would be
if some doorknob decided to change it--the objects are mutable, because
there's no good reason to make them immutable.
>
>
> Nevertheless, the world is full of doorknobs, and people will have to
deal with their code.

Speaking as a doorknob, I plan to use this PEP to allow wrapper functions
that accept arbitrary arguments to accurately report their signature as
matching the underlying function. It will also be useful for allowing
partial() objects (and other callables that tweak their API) to report an
accurate signature.

For example, I believe bound methods will misrepresent their signature with
the current PEP implementation - they actually should copy the function
signature and then drop the first positional parameter.

However, these use cases would be easier to handle correctly with an
explicit "copy()" method.

Also, +1 for keeping the lower level inspect functions around.

Cheers,
Nick.

--
Sent from my phone, thus the relative brevity :)
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-dev/attachments/20120607/aa3d1634/attachment.html>


More information about the Python-Dev mailing list