[Cython] Feature request: generate signature information for use by "inspect"

Stefan Behnel stefan_ml at behnel.de
Thu Jun 28 09:25:32 CEST 2012


Dieter Maurer, 28.06.2012 09:04:
> Python's "inspect" module is a great help to get valuable information
> about a package. Many higher level tools (e.g. the "help" builtin
> and "pydoc") are based on it.
> 
> I have just recognized a deficiency of "cython" generated
> modules with respect to "inspect" support:
> 
>      "inspect" cannot determine the signatures for Python functions
>      defined in "Cython" source.
> 
>      I understand that this might be a limitation of Python's "C"
>      interface.

Correct, although Cython goes to great length to enable introspection of
Cython implemented functions and classes (admittedly, we could still do
more...)


>      In this case, I suggest to enhance the
>      function's docstring by signature information.
> 
>      I now transform manually my docstrings
> 
>         def <rv> <f>(<signature>):
> 	  """<header>
> 
> 	  <detail>
> 	  """
> 
>      into:
> 
>         def <rv> <f>(<signature>):
> 	  """<f>(<signature>) -> <rv>: <header>
> 
> 	  <detail>
> 	  """
> 
>      and would be happy to get something similar automatically.

And the time machine strikes again. You can use the "embedsignature"
compiler option for that.

http://docs.cython.org/src/reference/compilation.html?highlight=embedsignature#compiler-directives

Stefan


More information about the cython-devel mailing list