Extend Python

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Tommy.Ryding@gmail.com

    #1

    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
    "intelligen t" 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

  • tooper

    #2
    Re: Extend Python

    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.

    Comment

    • Tommy.Ryding@gmail.com

      #3
      Re: Extend Python

      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?

      Comment

      • Ravi Teja

        #4
        Re: Extend Python

        SIP is not a commercial product and is released on a different license
        than PyQt.
        [color=blue]
        >From the SIP docs[/color]
        (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.


        Comment

        • Jake Gittes

          #5
          Re: Extend Python

          Try looking at ctypes -


          On 1 Sep 2005 05:12:21 -0700, Tommy.Ryding@gm ail.com wrote:
          [color=blue]
          >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[/color]

          Comment

          • Filip Dreger

            #6
            Re: Extend Python

            > My Question:[color=blue]
            > 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?[/color]

            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


            Comment

            • Jorgen Grahn

              #7
              Re: Extend Python

              On Thu, 1 Sep 2005 19:09:55 +0200, Filip Dreger <fdreger@amiga. pl> wrote:[color=blue][color=green]
              >> 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?[/color]
              >
              > 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.[/color]

              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!

              Comment

              • Tommy.Ryding@gmail.com

                #8
                Re: Extend Python

                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.

                Comment

                Working...