1 of 7

The C-API

Eric Snow

Language Summit

PyCon 2019

2 of 7

The C-API

  • historically fundamental to Python’s success
  • organic growth
  • early efforts to simplify
  • core devs: growing concerns
  • core devs: increasing efforts

2

3 of 7

The Problem

  • some problems (GIL, perf) need low-level changes
  • parts of public C-API expose low-level details (e.g. refcounts)
  • so...
  • fixing those problems requires breaking parts of C-API

3

4 of 7

The Solutions

  • someone has to care enough to do the work
  • physically separate the categories of C-API
  • more opaque structs

4

5 of 7

Categorizing the C-API

  • “internal”
  • “private”
  • “unstable”
  • “stable”

The "Include" directory is structured along these lines.

“Do not touch!”

“Use at your own risk!”

“Go for it (but rebuild your extension each Python release)!”

“Worry-free!”

5

6 of 7

The Solutions

  • someone has to care enough to do the work
  • physically separate the categories of C-API
  • more opaque structs
  • Python (C)FFI
  • break compatibility in a few places
  • deprecate C-API in favor of something like Cython (official)
  • maybe even completely replace the existing C-API
  • ...

6

7 of 7

Some of the Projects

Join us on <capi-sig@python.org>.

7