Python: SWIG vs ctypes

后端 未结 10 1596
无人共我
无人共我 2020-12-04 08:37

In python, under what circumstances is SWIG a better choice than ctypes for calling entry points in shared libraries? Let\'s assume you don\'t already have the SWIG interfac

10条回答
  •  暗喜
    暗喜 (楼主)
    2020-12-04 09:01

    ctypes is great, but does not handle C++ classes. I've also found ctypes is about 10% slower than a direct C binding, but that will highly depend on what you are calling.

    If you are going to go with ctypes, definitely check out the Pyglet and Pyopengl projects, that have massive examples of ctype bindings.

提交回复
热议问题