Extend Python

Discussion in 'Python' started by Tommy.Ryding@gmail.com, Sep 1, 2005.

  1. Guest

    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, 2005
    #1
    1. Advertising

  2. tooper Guest

    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.
     
    tooper, Sep 1, 2005
    #2
    1. Advertising

  3. Guest

    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, 2005
    #3
  4. Ravi Teja Guest

    Ravi Teja, Sep 1, 2005
    #4
  5. Jake Gittes Guest

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

    On 1 Sep 2005 05:12:21 -0700, 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
     
    Jake Gittes, Sep 1, 2005
    #5
  6. Filip Dreger Guest

    > 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
     
    Filip Dreger, Sep 1, 2005
    #6
  7. Jorgen Grahn Guest

    On Thu, 1 Sep 2005 19:09:55 +0200, Filip Dreger <> 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!
     
    Jorgen Grahn, Sep 3, 2005
    #7
  8. Guest

    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, 2005
    #8
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Raymond Hettinger

    Python Mystery Theatre -- Episode 3: Extend this

    Raymond Hettinger, Jul 22, 2003, in forum: Python
    Replies:
    1
    Views:
    302
    Raymond Hettinger
    Jul 22, 2003
  2. Peter Hansen

    newsgroup for embeded/extend python ?

    Peter Hansen, Aug 22, 2004, in forum: Python
    Replies:
    1
    Views:
    284
    skull
    Aug 23, 2004
  3. dataangel

    Using python to extend a python app

    dataangel, Mar 24, 2005, in forum: Python
    Replies:
    1
    Views:
    320
    David M. Cooke
    Mar 24, 2005
  4. Mile Blenton

    Extend/embedd python problem?

    Mile Blenton, Feb 16, 2006, in forum: Python
    Replies:
    0
    Views:
    298
    Mile Blenton
    Feb 16, 2006
  5. Charlie Miller
    Replies:
    0
    Views:
    341
    Charlie Miller
    Dec 9, 2006
Loading...

Share This Page