Which one is better for me , SIP or SWIG ?

Diez B. Roggisch deets at nospam.web.de
Sat Nov 18 12:21:17 CET 2006


fdu.xiaojf at gmail.com schrieb:
> Hi all,
> 
> I am going to generate a python wrapper of a C library, and I am 
> wondering which one is a better tool for me, SIP or SWIG ?
> 
> SWIG supports many scripting languages such as python, ruby, and perl, 
> while SIP is specific to python, so I think maybe SIP is more suitable 
> to generate better wrappers(sorry for my ignorance if I am wrong at this 
> point) with python.
> 
> But it seems that SIP is mainly used for pyQT and hasn't gained general 
> acceptance with python community.
> 
> Could someone give me a better comparison of SIP and SWIG ?
> 
> My concerns:
> 
>  1. I just want an python wrapper for C/C++ code. The support of other 
> scripting languages is not important.
> 
>  2. Easy to learn and easy to use.

The reasons SIP hasn't gained more attraction are dark to me. At least 
when it comes to C++, it's support is waaay better than SWIG. There also 
exists some Boost Python stuff, but I never wrapped my head around that.

However, if you are "only" wrapping C, pyrex is my tool of choice. It 
has build-in distutils support, and it is very easy to write. So if you 
can, go with pyrex. If you must wrap C++, go with SIP - boost 
non-withstanding.

Diez



More information about the Python-list mailing list