3

OS: CentOS 6 (64bit)

I have a dynamic library (.so) in C. And I want to create an abstraction layer of Python over it and then use it to implement my logic. I have decided to use CFFI for this since it doesn't deal with any kind of dsl (domain specific language).

Couple of things I wanted to know:

  1. Is there some good starting point which I can refer for doing this (loading and using dynamic libraries using cffi)? The docs on the official site talk about this, but I was looking if there was some concrete reference somewhere with some examples. Or someone who might have tried it.
  2. Can there a possible drawback to this approach?

Thanks

utsavanand
  • 329
  • 1
  • 3
  • 15
  • 1
    I searched github for "from cffi import FFI" and found this https://github.com/mwhooker/ffi_test/blob/master/cffi/test.py – djhoese Jul 25 '14 at 02:22

1 Answers1

4

Two good starting points:

Between the two you shouldn't have too much trouble putting together your wrapper.

And to your second question: if the shared library you're wrapping is very simple (ex, a few function calls, simle data structures) you might find ctypes simpler (as it's part of the standard library).

David Wolever
  • 148,955
  • 89
  • 346
  • 502