Question to python C API

Andreas Otto aotto1968 at onlinehome.de
Thu Apr 16 05:00:06 EDT 2009


Yes, you are right ...

  I read more and found the doc about this ...

  the problem I have is something more tricky ...

  I allready have an extension written for java
  and the easyest thing would be use this as template
  and replace the java specific calls with python calls ...

  but the python C API is much more complex than java JNI.

  I don't understand why because the task is allways the 
  same

  the problem is that i have a C api but don't want to
  use a 1 to 1 translation of the C functions to python.

  java generate the stub with java.h and you have to fill
  the stub with code even if it is just a function call
  of a C api function with near the same name.

  for me as user I would prefer the exact same way in python
  to:   1. write a python wrapper class
        2. declare all external function with "native"
        3. call python_h to create the necessary C header
        4. and let the user bill the body
        5. this require to have a clean and small language
                native interface (JNI fit on one web page 
                that's it)

  but i have helper functions which , for example, create 
  threads and python module have to attach to this thread.

  the problem with such kind of framework is usually
  that you start with the easy stuff and than (after a couple
  of days/weeks) you come to the difficult stuff and you
  have to figure out that this kind of problem does not
  fit into the tool.

  stuff what I do is:

        1. create objects on the fly as connection handle
        2. do callbacks from C to Python
        3. create and delete threads or manage to continue
                work after an fork 
        4. is server mode start an event-loop and never come
                back


  what I want:

        I want to use this tool but still be able to intermix
        parts of my "C" helper code with the python code

  question:

        it is possible to write C and python code into the 
        same file ?

        



More information about the Python-list mailing list