PyCon 2016 in Portland, Or
hills next to breadcrumb illustration

Monday 12:10 p.m.–12:40 p.m.

Here be Dragons - Writing Safe C Extensions

Paul Ross

Audience level:
Python Core (language, stdlib, etc.)


Writing Python Extensions can be daunting. This talk de-mystifies what you need to know to write reliable and blazingly fast Pythonic C code.


In the twilight world between Python and C lies the CPython API; you have to embrace not just C but Python's C API, which is huge. Now not only do you have to worry about just your standard malloc() and free() but now you also have to contend with how CPython manages its memory. This talk describes what you need to know to write fast, reliable Python extensions in 'C'. It demonstrates some of the pitfalls you can encounter and some simple and robust coding patterns that you can use to avoid them. After this talk you will be able to write Python extensions with confidence.