I have a Python script and a C program, and I need to transfer large amounts of data from a Python script that repeatedly call a C program. Right now I let the user choose between transferring them using an ASCII file or a binary file, but both are pretty slow and useless (I mean files that are useful if you want to save data, but I delete these files at the end of the script).
os.system does not work, there are too many arguments, since the C program also uses files to return data in Python, but this is much less data.
I wonder what I can use for a quick exchange? Writing files to a RAM disk? If so, how can I do this?
I heard that you can call functions from a DLL using ctypes, but I donโt know how to compile my program as a DLL (I use wxdevc + on Windows 7 64). Or wrap it, but still don't know if it can work and whether it is effective.
Data are the vertices of a three-dimensional grid.
I run a Python script inside another program ( blender (open source)), and it is called many times (usually more than 500 times) because it is inside a loop. The script sends vertex information (1 int index and 3 floatordinates) to the program and program should return many vertices (only int index, because I can find the corresponding vertices using Python).
So this is not interactive, it is more like a function (but it is written in C). The script + C program (which is in addition to blender) that I am writing must be cross-platform because it will be distributed.
The program is actually written in C, and from Python I can find out the address in the memory of the structure containing the vertex data. If only I know how to do this, it would be better to transfer only the address to the C-program, and from there find all the other vertices (stored in the list).
But, as far as I know, I canโt access the memory space of another program, and I donโt know if it calls a program with pipelines or something else, it initializes a new thread or runs inside a script (which actually runs under a blender thread )
Here is the source, and blender/source/blender/makesdna/DNA_meshdata_types.h should be a structure definition