← All notes

Get a callable's signature with inspect.signature

Answer: The Signature object represents the call signature of a callable object and its return annotation. Retrieve it with the signature() function. PEP 362 proposes this representation because the older introspection data was spread across a half-dozen deeply nested attributes.

What you get

inspect.signature(callable) returns a Signature for the given callable. The object also has a return annotation. Parameter objects and BoundArguments are part of the same design in the PEP. Some functions may not be introspectable.

Caching

The PEP discusses implicit caching of Signature objects. If the Signature object is cached, later changes to the function it describes will not be reflected in it. Caching can be always done manually.

| Signature | inspect | |---|---| | Signature | Call signature of a callable object and its return annotation | | signature() | Function that retrieves a Signature | | Parameter | Object in the PEP for one parameter | | BoundArguments | Object for arguments bound to a signature |

See also

Claims

Sources

License: this note is CC BY 4.0 (https://creativecommons.org/licenses/by/4.0/). Summary by iinventedlight (AI-assisted). Sources: Python PEPs, PEP 362 – Function Signature Object; Python docs, inspect — Inspect live objects. Public-Domain; PSF-2.0. Text was condensed and changed from the originals.

License: CC-BY-4.0 · Summary by iinventedlight (AI-assisted). Sources: Python PEPs, PEP 362 – Function Signature Object; Python docs, inspect — Inspect live objects. Public-Domain; PSF-2.0.

Cite this

Permanent ID: iil:note:9brg8dr5

iinventedlight. 2026. "Get a callable's signature with inspect.signature." iinventedlight Library, iil:note:9brg8dr5, version of 2026-11-19. https://iinventedlight.com/library/notes/python-inspect-signature/. License: CC-BY-4.0.

@misc{iil_note_9brg8dr5,
  author = {{iinventedlight}},
  title = {{Get a callable's signature with inspect.signature}},
  howpublished = {iinventedlight Library},
  year = {2026},
  date = {2026-11-19},
  url = {https://iinventedlight.com/library/notes/python-inspect-signature/},
  note = {Permanent ID iil:note:9brg8dr5. License: CC-BY-4.0.},
}

Markdown

Spotted a mistake? Use the MCP feedback tool or email hello@iinventedlight.com. Or Report a correction (no account needed).

Extra files beside this note

These files use this note's license, shown below. Paper extras retain their reproduction status; a link is not a reproduction.

All artifact files (JSON index)

For language models and agents: start at /llms.txt | /agents.md | /.well-known/agent-library.json. This page in Markdown: /library/notes/python-inspect-signature.md.