__signature__ attribute is an override for the
inspect.signature function, which returns the value of that attribute if present instead of computing it.
That behavior is not documented as part of the inspect.signature doc, but it is alluded to in
inspect.unwrap, and it is described in the implementation section of the signature PEP.
I think it’s a useful feature that’s not really hard to maintain (unlike the
__text_signature__ counterpart), and that it deserves to be documented.
Furthermore, the signature computation is expensive. The PEP states that " the
Signature object is created in a lazy manner, and is not automatically cached. However, the user can manually cache a Signature by storing it in the
__signature__ attribute." But that’s not true : unless
__signature__ is documented, the user is not at liberty to do that.
See issue 106310 and PR 106311.
Seems reasonable. Is there any reason you’ve posted this here, given that you’ve already raised an issue and PR? Unless there’s pushback on the tracker and it’s worth demonstrating community support for the proposal, it’s usually fine just to do the issue/PR.
Yes. It’s been on the tracker with no action being taken for some months now, I’m calling here so that it’s not lost in time (like tears in the rain).
I consider not documenting a special name a doc bug. I requested reviews from the Signature PEP authors. Hopefully, they will at least suggest someone else. If that does not get a response, use git blame on the inspect doc to see who wrote the mentions therein.
It’s been 10 days, so I checked the git blame : this commit introducing the
__signature__ mention in unwrap’s doc was authored by @ncoghlan (hi !), but apparently written by Daniel Urban and Aaron Iles (whom I don’t know the handles, if any).
Now merged, thanks everyone !