[SciPy-User] Wrapping C/C++ Code

Bruce Southey bsouthey@gmail....
Tue Nov 3 10:06:43 CST 2009


On 11/03/2009 09:23 AM, Rohit Garg wrote:
> The first thing to do is to expose an API from your program that your
> script can access. It'll likely not be done as  it was written with
> one language in mind.
>
> After that it's your call whether you want to embed or extend the
> interpreter. For extending, IMHO, SWIG is your friend.
>
> On Tue, Nov 3, 2009 at 4:46 PM, Lorenzo Isella<lorenzo.isella@gmail.com>  wrote:
>    
>> Dear All,
>> I hope this is not too off-topic.
>> If you were asked to wrap  C/C++ codes into a Python application
>> (potentially relying on NumPy/SciPy) which route would you follow?
>> Bear in mind that the initial C/C++ code is a standalone program which
>> was not written having Python in mind at all.
>> Many thanks
>>
>> Lorenzo
>>      
First you should determine if it is worth accessing that code/program. 
Since you are going to use numpy then it may be worth the effort to 
rewrite the required parts using numpy/scipy/Cython.

If you have no control over the development or it needs to be a 
standalone program then you probably should call it through Python. The 
reason is that you probably have little control over code maintenance 
and how any changes will impact your code.

If the code is a stable then I agree with Rohit that swig is a viable 
option.

Bruce







More information about the SciPy-User mailing list