Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What is the simplest, most productive approach to create prototype-grade Python bindings for existing C/C++ libraries?

I want to create simple prototype-grade Python bindings to evaluate various C/C++ libraries.

I need to experiment on Linux, Windows and Mac.

Some examples of the libs that I need bindings for include a mix of C or C++ libraries such as things like:

  • http://www.chokkan.org/software/cdbpp/
  • http://sourceforge.net/projects/dbh/
  • http://code.google.com/p/smhasher/wiki/MurmurHash3
  • http://www.seg.rmit.edu.au/zettair/
  • http://dbh.sourceforge.net/

There are several candidates out there, such as swig, ctypes, Boost.Python, pybindgen and questions were already posted here on the topic though the focus has been mostly on performance. Extending python - to swig, not to swig or Cython

I care more about getting something simple and quickly than about performance.

What would you recommend to pick for creating bindings quickly?

like image 690
Philippe Ombredanne Avatar asked Feb 24 '23 16:02

Philippe Ombredanne


2 Answers

ctypes fits the bill pretty well for C. It's ridiculously easy to make thin wrappers around C libraries with it.

like image 143
nmichaels Avatar answered Feb 27 '23 13:02

nmichaels


Have you considered Cython? It lets you bind to static libraries, and write your bindings in a language that looks like python.

like image 43
ʇsәɹoɈ Avatar answered Feb 27 '23 13:02

ʇsәɹoɈ