Learning C++ for Python Development

Nick Craig-Wood nick at craig-wood.com
Mon May 11 10:30:03 CEST 2009

joshua.pearce at gmail.com <joshua.pearce at gmail.com> wrote:
>  I am a recovering C# web developer who has recently picked up Django
>  and I'm loving it.
>  I would eventually like to get a job as a Django/Python developer. It
>  seems that many Python jobs require that you also be a C++ developer.
>  While I want to remain primarily a web developer, I don't want be
>  stuck doing CRUD applications, so I would like to learn C++ for Python
>  development. I have taken two basic programming courses in straight up
>  C++, no STL, Boost or anything like that, but I do have a very basic
>  knowledge of the language.
>  Can you folks suggest some Python packages which use C++ and are
>  relevant for web development, so I can dig through the source and
>  contribute in some way?
>  Or, just give me some general advice on learning C++ for Python?

I'm guessing that people who advertise for C++ and Python are
embedding python into C++ not extending python with C++.

Having done both things, I can say that embedding python into C++ is
not too much trouble, but that it is slightly easier to extend python
with C rather than C++ since the python executable is a C program not
a C++ program.

I'd start by reading this


And try some of the examples.

I'd also read all about ctypes


Which has saved me a huge amount of time in both the embedding and
extending cases!  One of the apps I've worked on is C++ but can have
"drivers" written in python run by an embedded python interpreter.
These drivers can call back into the C++ code, and the C++ can call
into the drivers.  That is done with a amount of C++ to load the
drivers and to export the C++ symbols into the python code at runtime
with ctypes.  A bit of C++ implements the shims for the callbacks from
python -> C++ (which are exported by ctypes).

>  P.S. I want to develop on Linux not Windows.

Should be just the same on both.  Once you've made your setup.py (for
extending python) the build process will work on all supported

Nick Craig-Wood <nick at craig-wood.com> -- http://www.craig-wood.com/nick

More information about the Python-list mailing list