PDA

View Full Version : Python and C++


krypto_wizard
March 9th, 2006, 12:05 PM
I was a C Programmer for a while. Lately started to learn Python for one small project at school. I joined a small company where they use C++ for development.

Can we use Python and C++ together ? I mean create some classes in Python and some number crunching algorithms coded in C++ (for speed) and integreate both of them.

Could somebody just show a real small example or give pointers to the same.

Thanks

hod139
March 9th, 2006, 03:01 PM
You can, and this has been done. http://numeric.scipy.org/

mdh
March 9th, 2006, 03:45 PM
You can call C++ routines from Python scripts using the swig interface. See swig homepage (http://www.swig.org/) for more information.

thumper
March 9th, 2006, 04:15 PM
I have used swig successfully for moderate sized projects.

For something small, I just did a hand crafted plug-in following the example in Python in a Nutshell.