...one of the most highly
regarded and expertly designed C++ library projects in the
world.
— Herb Sutter and Andrei
Alexandrescu, C++
Coding Standards
There are two basic models for combining C++ and Python:
The key distinction between extending and embedding is the location of the
C++ main()
function: in the Python interpreter executable, or in some other program,
respectively. Note that even when embedding Python in another program, extension
modules are often the best way to make C/C++ functionality accessible to
Python code, so the use of extension modules is really at the heart
of both models.
Except in rare cases, extension modules are built as dynamically-loaded libraries
with a single entry point, which means you can change them without rebuilding
either the other extension modules or the executable containing main()
.