Extend Python

T

Tommy.Ryding

Hi All I have a problem with extentions of Python.

Background:
I'm workin within a large industrial control system and I have created
a Port for VxWorks. In the system we have different permissions
depending on which state the controller is in. To perform some actions
in some states may even injure or kill people. Therefor we need
"intelligent" wrappers between Python and C-code.

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?

//T
 
T

tooper

PyQT is using SIP to wrap Qt : looks nice and works great for PyQt
which is a quite big wrapping. Never had the occation to use it myself
however, except for this.
 
T

Tommy.Ryding

What is Qt?

I have looked at PyQT and I can´t use it. I haven't tried it but the
PyQT license makes the program useless. :(

Any other suggestions?
 
R

Ravi Teja

F

Filip Dreger

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.

regards,
Filip Dreger
 
J

Jorgen Grahn

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
 
T

Tommy.Ryding

Thanx for all the answers.

I will write it myself I have done the simple part, wrapping some
functions. Didn't even take 15 minutes so it was really simple.

But I still have to solve the tricky parts. Wrap some complex
structures and pointers so I can use them from Python.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,580
Members
45,054
Latest member
TrimKetoBoost

Latest Threads

Top