[Tutor] Moving my C++ code to Python?

Chris Fuller cfuller084 at thinkingplanet.net
Sat Oct 16 05:51:31 CEST 2010

SWIG supports opaque pointers that you can pass into and out of Python without 
any problems.

Working with SWIG isn't that bad for basic stuff, although it can get 
complicated if you need to have it interpret exotica like references, 
structures, or such for Python.  Having a good C++ background should cut a lot 
of the difficulty out of that, though.  The documentation is pretty good, 
although finding what you need can involve a lot of scrolling around in long 
web pages.

If you are going to use a command line interface, you might check out these 
modules from the standard library:

You might also see if numpy can replace some of your C++ code.  It's fast, and 
integrated into Python.


On Friday 15 October 2010, Paul wrote:
> I would like to make modules for python.  The problem is that the
> vector of structs that is very large.  First, is it possible to pass
> such structures around to and from python and C/C++?  What would be
> the overhead cost of having a large structure that needs to be passed
> to and from the C/C++ modules?

More information about the Tutor mailing list