SWIG (available at
www.swig.org) is a tool written by David
helps connect programs written in high-level languages such as
Python, Perl, and Tcl/Tk with low-level C and C++ code. It’s a
substantial package with a large following. Rather than having to
write your own wrapper code to intermediate between Python and C data
structures, SWIG automates the process of producing a Python
extension based on a description of the functions you wish to export.
A large number of popular Python extensions have been built using
SWIG, including parts of the Win32 extensions. You should look into
SWIG before embarking on any nontrivial Python extension project.
Space doesn’t permit a detailed example of SWIG, but we refer you to the excellent documentation that comes with the package. This covers all the specifics relating to building Python extensions under Visual Studio.