SWIG overhead

John Roth JohnRoth1 at jhrothjr.com
Thu Feb 1 12:39:19 EST 2007


On Feb 1, 3:21 am, "Bart Ogryczak" <B.Ogryc... at gmail.com> wrote:
> Hi,
> I´m looking for some benchmarks comparing SWIG generated modules with
> modules made directly with C/Python API. Just how much overhead does
> SWIG give? Doing profile of my code I see, that it spends quiet some
> time in functions like _swig_setattr_nondinamic, _swig_setattr,
> _swig_getattr.


This isn't exactly what you're looking for, but I tried SWIG a while
ago, back when I still had a C compiler, and then decided to use c-
types.

The reason: I've got an aversion to anything that generates huge
steaming piles of incomprehensible code. Especially when I found a
couple of bugs in a SWIG-generated module I'd gotten from someone
else. This wasn't SWIG's fault, it was the author's for not
understanding the API he was wrapping properly, but I had to dig into
the SWIG code before I could figure out what was going on.

Bottom line: the c-types module was a lot smaller, in Python, and
completely comprehensible. And while I didn't measure the performance,
I doubt if it was slower.

John Roth




More information about the Python-list mailing list