Extend Python
Jorgen Grahn
jgrahn-nntq at algonet.se
Sat Sep 3 12:49:24 EDT 2005
On Thu, 1 Sep 2005 19:09:55 +0200, Filip Dreger <fdreger at amiga.pl> wrote:
>> My Question:
>> Swig offers some great features but is to basic for us. Is there
>> another program that creates more readble code that can be easily
>> edited? How much work is it to write our own wrappers?
>
> Not too much, and practicaly not at all if you want to wrap procedures
> (not objects or types):
> - marshaslling an argument list from Python to C and from C to Python
> takes exactly 1 line of code,
> - handling errors takes 2 lines of code (unless you want to do
> something fancy with them; I mean just catching an exception and
> getting the error message).
> - entry in the PyMethodDef is one simple line
> Bottomline: you need 5 additional lines of C code per procedure to
> make it usable from Python.
> Unless you have hundreds of procedures, there is no point in using
> special tools to do that. Especially if you need full control over the
> results.
My experience too. At least if you are a C programmer.
If it gets hard, it's because the things you wrap do something funky: take
complex memory structures as arguments, have odd resource management, etc.
A tool cannot help you with that anyway.
/Jorgen
--
// Jorgen Grahn <jgrahn@ Ph'nglui mglw'nafh Cthulhu
\X/ algonet.se> R'lyeh wgah'nagl fhtagn!
More information about the Python-list
mailing list