C Python extension to export an Function
Christian Gollwitzer
auriocus at gmx.de
Thu Sep 1 12:54:35 EDT 2016
Hi Ganesh,
Am 01.09.16 um 17:24 schrieb Ganesh Pal:
> Thanks stefan and Gollwitzer , good to know there are many ways to do this
> i.e via cython or SWIG but the C/Python API
> <https://docs.python.org/2/c-api/> is probably the most widely used method
> - not for it’s simplicity but for the fact that you can manipulate python
> objects in your C code.
I'm not sure you understood what SWIG or Cython do - they are not
circumventing the C/Python API, they merely write some of the code for
you (as a C file). With both you can add manually written C code if the
generated code is insufficient, and you can also ship the generated
code, so that SWIG or Cython are not needed to rebuild the module,
unless the API of your C coded functions changes.
> I want to use C/Python API <https://docs.python.org/2/c-api/>
You may have good reasons to do it manually anyway, in this case look at
the PyArg_ParseTuple and Py_BuildValue functions documented here
https://docs.python.org/2/c-api/arg.html
Christian
More information about the Python-list
mailing list