title: Best way to call executable and get output in python
body: <p>First a simple example to illustrate the situation. First the source .cpp that has been compiled into an executable:</p>
  
  <pre><code>#include &lt;iostream&gt;
  
  using std::cout;
  using std::endl;
  
  int main() 
  {
      cout &lt;&lt; "Hello World!" &lt;&lt; endl;
      return 0;
  }
  </code></pre>
  
  <p>This file has been made into an exe. Now in python it is called as follows:</p>
  
  <pre><code>import subprocess
  import sys
  
  sys.path.append('C:\Foo\Bar')
  
  output = subprocess.Popen("hello_world.exe", stdout=subprocess.PIPE)
  
  print output.stdout.read()
  </code></pre>
  
  <p>So this works fine for calling the executable and returning an output from the standard output. The question is, is there any feasible way to perform this to return potentially large arrays? From what I understand this is basically like returning and reading a text file, which would be quite slow! While I know SWIG or Cython are options for extending python with C++, I would find separate executable for each function more organized and modular!</p>
  
  <p>TLDR: Can you return large arrays from executables back to python at a reasonable speed? Or is extending with Cython/SWIG/ctypes the only way to go?</p>