What are the differences between SWIG and Boost.Python?

Mike Rovner mike at bindkey.com
Mon Apr 7 14:48:18 EDT 2003


"Bryan" <belred1 at yahoo.com> wrote in message
news:XSXja.346441$3D1.186570 at sccrnsc01...
> mike,
>
> you mentioned small c libs you use pyrex.  what about small but complex
data
> types?  we have a structures that contain pointers to structures that

Sure Pyrex has its limits. My picture was general. In each particular case I
weight pro and contra.

But it's especially nice to wrap C with Pyrex because it VERY easy to adapt
interface to pythonic way.
Say I had a lib with (void*) handle parameter to pass almost every data
structure and a bunch of different real structures.
With Pyrex an ability to redefine was a plus - hard things like swig and c++
will not do in that case (nicely I mean).
Complex (struct inside struct) data was no problem.
I also use a script to convert an .h file to Pyrex - it was simple 15-liner
__to run once__:

#!/usr/bin/env perl
/^\s*{\s*$/ && next;
/^\s*} T.*$/ && next;

s/;//;
s/^\t//;

s|/\*|\#|;
s|^ *\*|\#|;
s| *\*/$||;

s/^\s*typedef +struct +SSX([A-Z_]+)/cdef struct TSX$1:/; $n=$1 if $1;
s/^\s*struct/\ncdef struct $n:/;
s/^\s*}/\t$n/;

print;

WBR,
Mike








More information about the Python-list mailing list