Skip to content

paulross/PythonExtensionPatterns

 
 

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

Links are to Read the Docs.

  1. Introduction
  2. A Simple Example
  3. PyObjects and Reference Counting
  4. Containers and Reference Counts
  5. Struct Sequence Objects (a namedtuple in C)
  6. Exception Raising
  7. A Pythonic Coding Pattern for C Functions
  8. Parsing Python Arguments
  9. Creating New Types
  10. Setting and Getting Module Globals
  11. Logging and Frames
  12. File Paths and Files
  13. Subclassing and Using super()
  14. Capsules
  15. Iterators and Generators
  16. Context Managers
  17. Pickling C Extension Types
  18. Watchers [Python 3.12+]
  19. Setting Compiler Flags
  20. Debugging
  21. Memory Leaks
  22. Thread Safety
  23. Source Code Layout
  24. Using C++ With CPython Code
  25. Miscellaneous
  26. Installation
  27. Further Reading
  28. TODO
  29. History
  30. 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

Contributors 11