title: Pass many pieces of data from Python to C program
body: <p>I have a Python script and a C program and I need to pass large quantities of data from Python script that call many times the C program. Right now I let the user choose between passing them with an ASCII file or a binary file, but both are quite slow and useless (I mean files are useful if you want to store the data, but I delete these files at the end of the script).</p>
  
  <p><code>os.system</code> doesn't work, the arguments are too much as the C program too uses files to return data to Python, but this is much less data.</p>
  
  <p>I wonder what I can use to make this exchange fast. Writing the files to a RAM disk? If so, how can I do this?</p>
  
  <p>I heard is possible to call functions from DLL using ctypes, but 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 if it is efficient.</p>
  
  <p>The data are vertices of a 3D mesh.</p>
  
  <p>I'm running the Python script inside another program (<a href="http://www.blender.org/" rel="nofollow noreferrer">blender</a> (open source), and is called many times (usually more than 500 times) because it's inside a cycle. The script send vertices information (1 <code>int</code> index and 3 float coords) to the program, and the program should return many vertices (only int index, because I can find the corresponding vertices with Python).</p>
  
  <p>So this is not interactive, it's more like a function (but it's wrote in C). The script + C program (that are add-ons of blender) that I'm writing should be cross-platform because it will be redistributed.</p>
  
  <p>The program is actually wrote in C, and from Python I can know the address in memory of the struct that contains the vertices data. If only I know how to do this, should be better to pass to the C program only an address, and from there find all the other vertices (are stored in list).</p>
  
  <p>But as far as I know, I can't access to the memory space of another program, and I don't know if calling the program with pipes or whatever initialize a new thread or is run inside the script (that is actually run under the Blender thread)</p>
  
  <p><a href="https://svn.blender.org/svnroot/bf-blender/trunk/blender/" rel="nofollow noreferrer">Here is the source</a> and <code>blender/source/blender/makesdna/DNA_meshdata_types.h</code> should be the struct definition</p>