[Tutor] c++ on python

Stefan Behnel stefan_ml at behnel.de
Thu Mar 13 16:57:05 CET 2014


Alan Gauld, 12.03.2014 23:05:
> On 12/03/14 16:49, Stefan Behnel wrote:
>> Alan Gauld, 12.03.2014 10:11:
>>> If it were a library then you would have to call
>>> the individual C++ functions directly using
>>> something like ctypes, which is usually more
>>> complex.
>>
>> ctypes won't talk to C++, but Cython can do it quite easily.
> 
> I thought it would work provided the interface functions
> were declared as C functions? That might involve
> writing a wrapper around it but that is usually
> trivial if you have to compile the source anyway.

The thing is: if you have to write your own wrapper anyway (trivial or
not), then why not write it in Cython right away and avoid the intermediate
plain C level?

It's usually much nicer to work with object oriented code on both sides
(assuming you understand the languages on both sides), than to try to
squeeze them through a C-ish API bottleneck in the middle.

Stefan




More information about the Tutor mailing list