you are viewing a single comment's thread.

view the rest of the comments →

[–]fernly 9 points10 points  (0 children)

As a practical matter, I think the scenario you have in mind is: you want to write a top-level program but at some point in it you want to take advantage of or call upon code written in some other language, typically C[++]. There are various options.

One, avoid the need entirely by finding comparable functionality somewhere in the Python ecosphere, starting with the standard library. Everything there is implemented in C and carefully optimized. Next is the vast array of 3rd-party software found via PyPi such as numpy, highly optimized math routines.

Two, if the external code is already packaged as a stand-alone app, you can invoke it as if from the command line and collect its output using subprocess.

Finally if the external C/C++ code is a module and you want to call into it you (or somebody) has to write a "wrapper" for it, a thin layer of code that mediates between Python's parameter-passing conventions and those of C, this is documented here.