Skip to content

[mypyc] Generate introspection signatures for compiled functions #19307

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 4 commits into
base: master
Choose a base branch
from

Conversation

brianschubert
Copy link
Collaborator

Refs mypyc/mypyc#838

This PR populates __text_signature__ for compiled functions, making runtime signature introspection possible (i.e. inspect.signature(func)).

While __text_signature__ is an undocumented CPython implementation detail, other extension module generators are using it in practice. For example, PyO3 and Cython both support it. I think it would be reasonable for mypyc to support it too.

Some function signatures can't be represented by __text_signature__ (namely, those with complex default arguments). In those cases, no signatures are generated (same as the current behavior).

@brianschubert brianschubert added the topic-mypyc mypyc bugs label Jun 16, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
topic-mypyc mypyc bugs
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant