views:

64

answers:

1

Hi All

I have a C program and a Python program on the same machine. The C program generates some data in nested structures. What form of IPC is the best way to get this data across to the python program?

Serializing in C (especially nested structures) is a real bear, from what I hear, due to lack of serialization libraries. I am not very familiar with shared memory, but I assume the formatting of the C structures may not be very palatable to the python program when it comes to memory alignment and following pointers. The ctype and struct library seems to be for non-nested structures only. So far, what I am thinking is:

Wrap all the data in the C program into some xml or json format, write it via socket to python program and then let python program interpret the xml/json formatted data. Looks very cumbersome with lots of overheads.

Any better ideas ?

+2  A: 

I think you answered your own question. JSON is certainly a good choice. It's also not terribly difficult to do your own serialization in C.

R..