GNU Info

Info Node: (python2.1-ext.info)Extending Python with C or C++

(python2.1-ext.info)Extending Python with C or C++


Next: Defining New Types Prev: Front Matter Up: Top
Enter node , (file) or (file)node

Extending Python with C or C++
******************************

It is quite easy to add new built-in modules to Python, if you know how
to program in C.  Such "extension modules" can do two things that can't
be done directly in Python: they can implement new built-in object
types, and they can call C library functions and system calls.

To support extensions, the Python API (Application Programmers
Interface) defines a set of functions, macros and variables that
provide access to most aspects of the Python run-time system.  The
Python API is incorporated in a C source file by including the header
`"Python.h"'.

The compilation of an extension module depends on its intended use as
well as on your system setup; details are given in later chapters.

A Simple Example
Intermezzo Errors and Exceptions
Back to the Example
Module's Method Table and Initialization Function
Compilation and Linkage
Calling Python Functions from C
Extracting Parameters in Extension Functions
Keyword Parameters for Extension Functions
Building Arbitrary Values
Reference Counts
Writing Extensions in C++
Providing a C API for an Extension Module

automatically generated by info2www version 1.2.2.9