Skip to content

paulross/PythonExtensionPatterns

Folders and files

NameName
Last commit message
Last commit date

Latest commit

b2b1ba8 · Mar 20, 2025
Mar 14, 2021
Mar 20, 2025
Mar 19, 2025
Mar 18, 2025
Jul 24, 2024
Dec 22, 2024
Aug 28, 2014
Aug 28, 2014
Jul 29, 2024
Mar 16, 2025
Mar 20, 2025
Feb 6, 2025
Mar 20, 2025
Jan 8, 2025
Mar 20, 2025
Mar 11, 2025
Mar 7, 2025
Mar 19, 2025

Repository files navigation

PythonExtensionPatterns

If you need to write C extension for Python then this is the place for you.

The full documentation is on Read the Docs.

Code examples and documentation source are on GitHub. The example and test code is available on PyPi.

Subjects Covered

  • Introduction
  • A Simple Example
  • PyObjects and Reference Counting
  • Containers and Reference Counts
  • Struct Sequence Objects (a namedtuple in C)
  • Exception Raising
  • A Pythonic Coding Pattern for C Functions
  • Parsing Python Arguments
  • Creating New Types
  • Setting and Getting Module Globals
  • Logging and Frames
  • File Paths and Files
  • Subclassing and Using super()
  • Capsules
  • Iterators and Generators
  • Context Managers
  • Pickling C Extension Types
  • Watchers [Python 3.12+]
  • Setting Compiler Flags
  • Debugging
  • Memory Leaks
  • Thread Safety
  • Source Code Layout
  • Using C++ With CPython Code
  • Miscellaneous
  • Installation
  • Further Reading
  • TODO
  • History
  • Index

Project Links

Videos

I have presented some of this, well mostly the chapter "PyObjects and Reference Counting", at Python conferences so if you prefer videos they are here:

About

Examples of safe coding practice for Python C extensions.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published