# Documented features and implementation details around \_\_signature\_\_

**URL:** <https://discuss.python.org/t/documented-features-and-implementation-details-around-signature/47282>\
**Category:** Documentation\
**Created:** [March 1, 2024, 10:13am UTC](https://discuss.python.org/t/documented-features-and-implementation-details-around-signature/47282 "2024-03-01T10:13:17Z")\
**Posts on this page:** 1\
**Showing post:** 2

<div class="post-metadata">

**Author:** ![skirpichev](https://sea2.discourse-cdn.com/flex002/user_avatar/discuss.python.org/skirpichev/32/10996_2.png) [@skirpichev](https://discuss.python.org/u/skirpichev)\
**Post date:** [March 1, 2024, 11:51am UTC](https://discuss.python.org/t/documented-features-and-implementation-details-around-signature/47282/2 "2024-03-01T11:51:20Z")

</div>

> [@Gouvernathor](#):
>
> More than a year ago, [the behavior changed](https://github.com/python/cpython/issues/100039) (in a backwards-compatible way) by gaining undocumented support for strings and callables, as a special shoehorn for Enum.

JFR, that special logic could be reverted back, keeping added features for the Enum. Patch: [gh-115937: remove extra processing for the \_\_signature\_\_ attribute by skirpichev · Pull Request #115984 · python/cpython · GitHub](https://github.com/python/cpython/pull/115984)

Also, years after the [PEP 362](https://peps.python.org/pep-0362/), the type check was added to solve [inspect.signature doesn't always return a signature · Issue #66000 · python/cpython · GitHub](https://github.com/python/cpython/issues/66000). Perhaps, a managed attribute that check type in the setter could be better as a solution: then the exception will be raised in a right time and in a less surprising place.

Is there reasons why we would like to keep more complex handling for this special attribute?

Given above, the documentation could be rephrased as: “If the object has a ` __signature__ ` attribute and if it is not `None`, this function returns it.” Just as it was designed in the PEP, IIUIC.

> [@Gouvernathor](#):
>
> uses of ` __signature__ ` as a cache or as a way to hide undocumented parameters remains guaranteed

Also, while in practice, probably, this will be tedious and inconvenient (see [Signatures for extension modules (PEP draft)](https://discuss.python.org/t/signatures-for-extension-modules-pep-draft/43914), for some alternative) — this attribute actually the only way how people could support introspection for extension modules.

But it worth to note, that the PEP 362 has limitations, the inspect module can’t yet represent functions with multiple signatures (see e.g. [Signatures, a call to action](https://discuss.python.org/t/signatures-a-call-to-action/23580)). Maybe this is an argument for we shouldn’t expose ` __signature__ ` as public? Wouldn’t be the ` __signatures__ ` as “list of Signature objects or None” - better?

Sorry, if this a bit off-topic and changes in logic shouldn’t be discussed here. @erlendaasland suggested me to start jet another thread on d.p.o, but I think it will be overkill:)

---

_[View the full topic](https://discuss.python.org/t/documented-features-and-implementation-details-around-signature/47282)._
