Learning C++ for Python Development

Roger Binns rogerb at rogerbinns.com
Mon May 11 08:55:52 CEST 2009


-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

joshua.pearce at gmail.com wrote:
> Or, just give me some general advice on learning C++ for Python?

You may want to start with Cython first.  It lets you intersperse C and
C level information with Python code to produce extensions.  That will
give you a gentler introduction to using a C like language with Python
and for many real world uses is actually sufficient to get C levels of
performance and interfacing with Python.

After you get that working then you can try coding your own extensions
(the Python docs include all the necessary information) and also trying
other tools such as SWIG which automate some of the code for wrapping
C++, or the wrapping functionality present in Boost.

I find it most helpful to explore doing the same thing in multiple
different ways as it teaches you what is important and what isn't.
Later on it will help you a lot better in choosing the right tool for
the job (no one tool or approach is perfect) and help evaluate anything
that comes up later.

My suggestion would be to pick a particular task and code it in pure
Python.  Benchmark it (cpu and memory) and then try the other approaches
(Cython, Boost, hand coded, SWIG) and see how they compare.  Something
like a brute force Suduko solver would let you have a few
classes/objects but not be too much code.

Roger
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.9 (GNU/Linux)

iEYEARECAAYFAkoHy/QACgkQmOOfHg372QTxywCgrJPcHLQ5BzD8O29nSAW+I5xo
juYAnjMP0xqn/TzC5mrTCqBT3ZnIQo24
=KeIk
-----END PGP SIGNATURE-----




More information about the Python-list mailing list