Advice on Python C modules

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Torsten Marek

    Advice on Python C modules

    Hello all,

    I think about rewriting one C++ library with Python wrappers (by sip) to
    a pure Python module (because I just use it from Python).

    I have to create custom types and inherit from those custom types.
    Is it better to use pure C for that module, Pyrex or should I stay with
    my current library (which has to be modified for some other reasons, too)?

    thanks for your time

    greets

    Torsten

  • Mike Rovner

    #2
    Re: Advice on Python C modules

    Torsten Marek wrote:[color=blue]
    > I think about rewriting one C++ library with Python wrappers (by sip)
    > to a pure Python module (because I just use it from Python).
    >
    > I have to create custom types and inherit from those custom types.
    > Is it better to use pure C for that module, Pyrex or should I stay
    > with my current library (which has to be modified for some other
    > reasons, too)?[/color]

    It seems to me that you contradict yourself here.
    Pure python is pure python without any c, c++, pyrex, sip, etc.
    OTOH, if you still need compiled extension for some reason
    (usualy only two excuses are good enough- speed and low-level
    interface to something as hardware or 3rd party libraries)
    why throw out good working code? It's not a good practice.

    So if you don't *have to* use compiled extension you can ask how to achieve
    desired results in pure python.

    Mike




    Comment

    • Torsten Marek

      #3
      Re: Advice on Python C modules

      Mike Rovner schrieb:[color=blue]
      > Torsten Marek wrote:
      >[color=green]
      >>I think about rewriting one C++ library with Python wrappers (by sip)
      >> to a pure Python module (because I just use it from Python).
      >>
      >>I have to create custom types and inherit from those custom types.
      >>Is it better to use pure C for that module, Pyrex or should I stay
      >>with my current library (which has to be modified for some other
      >>reasons, too)?[/color]
      >
      >
      > It seems to me that you contradict yourself here.
      > Pure python is pure python without any c, c++, pyrex, sip, etc.
      > OTOH, if you still need compiled extension for some reason
      > (usualy only two excuses are good enough- speed and low-level
      > interface to something as hardware or 3rd party libraries)
      > why throw out good working code? It's not a good practice.
      >
      > So if you don't *have to* use compiled extension you can ask how to achieve
      > desired results in pure python.
      >[/color]
      You're right, sorry. What I meant was compiled extension, because I need
      access to 3rd party libs and I do not want to use their Python bindings
      for speed reasons.

      Torsten

      Comment

      Working...