Back to Arangodb

Background

3rdParty/boost/1.78.0/libs/python/doc/html/building/background.html

3.12.9.12.1 KB
Original Source

| |


Background

There are two basic models for combining C++ and Python:

  • extending, in which the end-user launches the Python interpreter executable and imports Python “extension modules” written in C++. Think of taking a library written in C++ and giving it a Python interface so Python programmers can use it. From Python, these modules look just like regular Python modules.
  • embedding, in which the end-user launches a program written in C++ that in turn invokes the Python interpreter as a library subroutine. Think of adding scriptability to an existing application.

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().

| | Copyright © 2002-2015 David Abrahams, Stefan Seefeld
Copyright © 2002-2015 David Abrahams, Stefan Seefeld

Distributed under the Boost Software License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)

|