Python: SWIG vs ctypes

后端 未结 10 1592
无人共我
无人共我 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:04

    In my experience, ctypes does have a big disadvantage: when something goes wrong (and it invariably will for any complex interfaces), it's a hell to debug.

    The problem is that a big part of your stack is obscured by ctypes/ffi magic and there is no easy way to determine how did you get to a particular point and why parameter values are what they are..

提交回复
热议问题