# Extending and Embedding the Python Interpreter

Guido van Rossum

Corporation for National Research Initiatives (CNRI)
1895 Preston White Drive, Reston, Va 20191, USA
E-mail: guido@CNRI.Reston.Va.US, guido@python.org

April 13, 1999
Release 1.5.2

- Front Matter
- Contents
- 1. Extending Python with C or C++
  - 1.1 A Simple Example
  - 1.2 Intermezzo: Errors and Exceptions
  - 1.3 Back to the Example
  - 1.4 The Module's Method Table and Initialization Function
  - 1.5 Compilation and Linkage
  - 1.6 Calling Python Functions from C
  - 1.7 Format Strings for `PyArg_ParseTuple()`
  - 1.8 Keyword Parsing with `PyArg_ParseTupleAndKeywords()`
  - 1.9 The `Py_BuildValue()` Function
  - 1.10 Reference Counts
  - 1.11 Writing Extensions in C++
  - 1.12 Providing a C API for an Extension Module
- 2. Building C and C++ Extensions on Unix
  - 2.1 Building Custom Interpreters
  - 2.2 Module Definition Options
  - 2.3 Example
  - 2.4 Distributing your extension modules
- 3. Building C and C++ Extensions on Windows
  - 3.1 A Cookbook Approach
  - 3.2 Differences Between Unix and Windows
  - 3.3 Using DLLs in Practice
- 4. Embedding Python in Another Application
  - 4.1 Embedding Python in C++
- About this document ...