Possible Duplicate:
Integrate Python And C++
I am the python GUY and do web stuff in django. I want to know that how easy or hard it is to integrate python and C++ using SWIG.
Is it efficient/easy to do or should leave C++ and code the things in python.
There are some things C++ files which have been coded already by the past programmers. I know that SWIG is used to integrate languages but i don’t know what practical implications or problems are there for using it.
or There is no use of it and re-writing code in Python is the better choice.
I often use swig for work in order to translate code to multiple languages and it is a really useful tool.
In order to understand what is the best way for you, you should observe your software interfaces. If you c++ classes have methods that only receive and returns simple types like strings or stl structures, you can be confident that your code doesn’t have problems being “swigged”. The problems come to you when you have complex interfaces.
An another issue with python is the presence of GIL that in multithreaded environments (with blocking calls in c++ side) can cause a lot of problems and involves in a complex management (using python-dev library in your c++ code).
A suggestion if your destination code is written only in python is to take a look of boost-python libraries that, being more specialized, are often more simple to use with python. The problems with multithreaded environments, however, remain.