Wednesday, 2 June 2010

Cython, the new frontier

Learning to write in Cython, a novel alternative to writing native python extensions in raw C.

Stand by for updates...

Meanwhile an overvire of the many ways to interface python with native programs and libraries:
  1. integrate through files, sockets, pipes or even mmap and shm
  2. write extension in C
  3. write extension in C and wrap it in Python module
  4. write module in mix of C and Python and translate with Cython
  5. use native library via ctypes
  6. use native library via ctypes and wrap in a Python module
  7. generate wrappers with SWIG
  8. write all in Python, numpy for performance
1st is the easiest to start with, but doesn't offer tight control over native program's execution, such as timing, errors, feedback.

2nd and 3rd are quite sane, and after a bit of learning even quite easy to debug. The advantage of a Python wrapper is to split the 2 parts of integration, the C and Python so that programming is the easiest.

0 comments: