C Python extension to export an Function

dieter dieter at handshake.de
Thu Sep 1 03:02:16 EDT 2016


Ganesh Pal <ganesh1pal at gmail.com> writes:

> Iam pretty new to C Python extension , I was able to export few simple
> modules to python and it look like the cool thing to do ...

Maybe, it is a good idea to have a look at "cython".

"cython" is a compiler. It translates Python code enhanced with
special annotations into C. The annotations mostly tell the compiler
that something ("object", "method", "function", ...) should be at "C"
rather than "Python" level, thus avoiding much of Python's overhead
and allows to do things possible in "C" but not in "Python".


Developing safe "C" extensions for Python is difficult. You
need some quite deep understanding of the Python-C interface
and must be very careful to observe all requirements (especially
those related to proper reference management).

Developing "C" extensions with "cython" is much easier as
"cython" hides many of the complexities and takes care of most
requirements.




More information about the Python-list mailing list