Chapter 27. Extending and Embedding Python

THIS CHAPTER COVERS THE C API USED TO BUILD extension modules and embed the Python interpreter into other applications. It’s not intended to be a tutorial, so readers may want to consult the “Embedding and Extending the Python Interpreter” document available at, as well as the “Python/C API Reference Manual” available at

The primary focus of this chapter is to cover the most common cases. Advanced extension-building techniques such as defining entirely new Python types is not covered. This omission is intentional; most advanced extension-building problems are better handled by extension-building tools such as Boost Python and SWIG. References ...

Get Python: Essential Reference, Third Edition now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.