title: How to introspect a function defined in a Cython C extension module
body: <p>Python's <a href="https://docs.python.org/3/library/inspect.html" rel="noreferrer"><code>inspect</code></a> module doesn't seem to be able to inspect the signatures of "built-in" functions, which include functions defined in C extension modules, like those defined by Cython. Is there any way to get the signature of a Python function you have defined in such a module, and specifically in Cython? I am looking to be able to find the available keyword arguments.</p>
  
  <p>MWE:</p>
  
  <pre><code># mwe.pyx
  def example(a, b=None):                                                                                                                                                       
      pass       
  </code></pre>
  
  <p>and</p>
  
  <pre><code>import pyximport; pyximport.install()                                                                                                                                         
  import mwe                                                                                                                                                                    
  import inspect                                                                                                                                                                
  
  inspect.signature(mwe.example)   
  </code></pre>
  
  <p>yields:</p>
  
  <pre><code>Traceback (most recent call last):                                                                                                                                           
    File "mwe_py.py", line 5, in &lt;module&gt;                                                                                                                                      
      inspect.signature(mwe.example)                                                                                                                                           
    File "/nix/store/134l79vxb91w8mhxxkj6kb5llf7dmwpm-python3-3.4.5/lib/python3.4/inspect.py", line 2063, in signature                                                         
      return _signature_internal(obj)                                                                                                                                          
    File "/nix/store/134l79vxb91w8mhxxkj6kb5llf7dmwpm-python3-3.4.5/lib/python3.4/inspect.py", line 1965, in _signature_internal                                               
      skip_bound_arg=skip_bound_arg)                                                                                                                                           
    File "/nix/store/134l79vxb91w8mhxxkj6kb5llf7dmwpm-python3-3.4.5/lib/python3.4/inspect.py", line 1890, in _signature_from_builtin                                           
      raise ValueError("no signature found for builtin {!r}".format(func))                                                                                                     
  ValueError: no signature found for builtin &lt;built-in function example&gt;    
  </code></pre>
  
  <p>In Python 3.4.5 and Cython 0.24.1</p>