Simplified Wrapper and Interface Generator
SWIG (available at
www.swig.org) is a tool written by David
Beazley that
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.
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access