473,468 Members | 1,627 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

Extend Python

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
7 1639
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
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
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
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
> 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
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
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: disgracelands | last post by:
I've been looking at using python and it's been going fairly well so far, i can call C from python and python from C fine but now i've hit a snag and i'm wondering how you guys have got around it....
75
by: David MacQuigg | last post by:
Seems like we need a simple way to extend Python syntax that doesn't break existing syntax or clash with any other syntax in Python, is easy to type, easy to read, and is clearly distinct from the...
1
by: skull | last post by:
Hi, everyone I wanna know is there any newsgoup(or forums through www) specially for embeded/extend python? thanks in advance -skull
24
by: Jean-Baptiste PERIN | last post by:
Hi, I'm trying to make a windows dll reachable from a python script .. and I'm encountering troubles during link step .. I use "lcc" to compile and link I use python 2.3 under win XP ...
9
by: Tuvas | last post by:
I am looking for a good tutorial on how to extend python with C code. I have an application built in C that I need to be able to use in Python. I have searched through various sources, starting of...
2
by: mr_gees100_peas | last post by:
Hi, I've been trying for days to make either boost.python or swig to work for me. The one I have gotten the closest to is boost. Note that this is for windows XP. I'm not much of an unix person...
1
by: nimitsis | last post by:
Hello everyone I am trying to use a module , which I have create by using Swig. This module has C code with embedded Python . The relative code follows : // main.c #include "Python.h"...
1
by: nimitsis | last post by:
Hello everyone I try to extend Python using a simple C wrapped module . This module includes embedded python code and it is product of Swig . The corresponding files follows : //main.c #include...
4
by: spectrumdt | last post by:
Hello. I am trying to extend Python with some C code. I made a trivial "Hello World" program in C that I am trying to wrap in "boilerplate" for inclusion in a Python program. But I can't compile...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.