Go to content

Sophia Davis - Peeking into Python’s C API

Sophia Davis - Peeking into Python’s C API [EuroPython 2016] [22 July 2016] [Bilbao, Euskadi, Spain] (https://ep2016.europython.eu//conference/talks/peeking-into-pythons-c-api) Ever wondered how Python works under the hood? One way to learn about Python-the-C-program is by exploring the C API for writing Python bindings to native C libraries. In this talk, we will walk through a simple example of making a C library callable from Python code and vice versa. Along the way, we will encounter some essential features of Python: reference counting, memory management, and the inner- workings of objects and modules. ----- We all love Python. It’s so elegant and easy to use as a programming language that we forget about the giant, complicated C program executing our strings of white-space sensitive code. For many Python programmers, this side of Python is just a big black box. It works well, so thankfully we don’t *need* to go messing around inside... but what if you *want* to look into the inner workings of this powerful tool? One way to dive into the C-program-side of Python is by exploring the C API for writing Python bindings to native C libraries. In this talk I will explore the basics of this API as I recount my journey to make a simple C library callable from Python code, and allow C code to invoke objects defined in pure Python. Along the way, we will encounter some essential features of Python: reference counting, memory management, and the inner-workings of objects and modules.

July 17, 2016