Providing a Python wrapper to a C++ type.

Stefan Behnel stefan_ml at behnel.de
Tue Oct 16 08:16:10 EDT 2012


Marco Nawijn, 16.10.2012 13:46:
> I never worked with Cython (but I know it is very powerful and
> interesting) but in my mind there are slight differences in usage
> scenario between e.g. Boost Python and Cython. For me the idea of Cython
> is that your main code is in Python

Normally, yes. You can embed Cython code in C++ just like any other C code
(with the caveat of needing to make sure the Python runtime is properly set
up), but that certainly isn't the most popular use case.


> but you want to improve the
> performance of specific parts of the code. In that case, Cython is the
> way to go. In case of Boost Python, the scenario for me is that you have
> a main program/library in C++, but you want to be able use the
> functionality from Python.

That's really just a slight difference. What kind of code initially started
up an application is quite irrelevant once it has been running for a while.
The distinction between embedding and extending, as the Python docs put it,
is actually quite fuzzy when it comes to the actual code interaction.

Note also that this isn't the use case here, the OP asked for wrapping a
C++ type for use in Python.

Stefan




More information about the Python-list mailing list