1

I have two questions: 1) I want to call a C library from a Python application. I don't want to wrap the whole API, I want only the functions and datatypes that are relevant to my purpose.

As I see it, I have two choices:

  1. Use Cython to expose the relevant parts from the C library to Python.
  2. Do the whole thing in Python, using ctypes to communicate with the external library.

I'm not sure whether 1) or 2) is the better choice.

We may have some changes in the function prototypes or need to support few more functions over time.So,I thought using cython or some other tool might be better.

Are there more advantages / disadvantages with either choice? Which approach do you recommend?

2).Also I am newbie to Python and cython. If possible can somebody give some example on how to call c library from python app? I browsed over net, but could not get any example working. I might be missing some thing.

Any help will be really appreciated.

user1733051
  • 61
  • 1
  • 5
  • You may want to split this into two questions, one about how to interface with C, and one about the specific problems you've had calling C from your python app. – Collin Oct 09 '12 at 21:34
  • Could some body help me out. Thanks. – user1733051 Oct 10 '12 at 21:50
  • Deciding between the two is best answered here: http://stackoverflow.com/questions/1942298/wrapping-a-c-library-in-python-c-cython-or-ctypes – Mike Sandford Dec 10 '12 at 23:51

0 Answers0