By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
440,621 Members | 1,077 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 440,621 IT Pros & Developers. It's quick & easy.

Extend Python

P: n/a
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

Sep 1 '05 #1
Share this Question
Share on Google+
7 Replies


P: n/a
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.

Sep 1 '05 #2

P: n/a
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?

Sep 1 '05 #3

P: n/a
SIP is not a commercial product and is released on a different license
than PyQt.
From the SIP docs

(http://www.river-bank.demon.co.uk/do...f.html#license)
1.1 License
SIP is licensed under the same terms as Python itself. SIP places no
restrictions on the license you may apply to the bindings you create.

On a side note.. there will be a GPL edition of PyQt sometime in the
future.
http://www.riverbankcomputing.co.uk/pyqt/roadmap.php

Sep 1 '05 #4

P: n/a
Try looking at ctypes -
http://starship.python.net/crew/theller/ctypes/

On 1 Sep 2005 05:12:21 -0700, To**********@gmail.com wrote:
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


Sep 1 '05 #5

P: n/a
> 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
--
Akademia Linuksa - http://www.akademia.linuksa.pl
Sep 1 '05 #6

P: n/a
On Thu, 1 Sep 2005 19:09:55 +0200, Filip Dreger <fd*****@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!
Sep 3 '05 #7

P: n/a
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.

Sep 5 '05 #8

This discussion thread is closed

Replies have been disabled for this discussion.