Convert macros to functions in the Python C API

 — 
L'oeil du cyclone - Théo Grosjean

Drawing: "L'oeil du cyclone" by Théo Grosjean.

Convert macros to functions

For 4 years, between Python 3.7 (2018) and Python 3.12 (2022), I made many changes on macros in the Python C API to make the API less error prone (avoid macro pitfalls) and better define the API …

Category: cpython Tags:

Debug a Python reference leak

 — 
Childhood memories in the countryside

This morning, I got this email from the buildbot-status mailing list:

The Buildbot has detected a new failure on builder PPC64LE Fedora Rawhide Refleaks 3.x while building Python.

I get many of buildbot failures per month (by email), but I like to debug reference leaks: they are more challenging …

Category: cpython Tags:

Python C API: Add functions to access PyObject

 — 
A spider in my bedroom

The PyObject structure prevents indirectly to optimize CPython. We will see why and how I prepared the C API to make this structure opaque. It took me 1 year and a half to add functions and to introduce incompatible C API changes (fear!).

In February 2020, I started by adding …

Category: cpython Tags:

C API changes between Python 3.5 to 3.10

 — 
Homer Simpson hiding

I'm trying to enhance and to fix the Python C API for 5 years. My first goal was to shrink the C API without breaking third party C extensions. I hid many private functions from the public functions: I moved them to the "internal C API". I also deprecated and …

Category: cpython Tags:

Creation of the pythoncapi_compat project

 — 
Strange Cat by Kéké

In 2020, I created a new pythoncapi_compat project to add Python 3.10 support to C extensions without losing support for old Python versions. It supports Python 2.7-3.10 and PyPy 2.7-3.7. The project is made of two parts:

  • pythoncapi_compat.h: Header file providing new C API …
Category: cpython Tags:

Make structures opaque in the Python C API

 — 
OVHcloud datacenter fire in Strasbourg

This article is about changes that I made, with the help other developers, in the Python C API in Python 3.8, 3.9 and 3.10 to avoid accessing structures members: prepare the C API to make structures opaque. These changes are related to my PEP 620 "Hide implementation …

Category: cpython Tags:

Isolate Python Subinterpreters

 — 
Christmas gift.

This article is about the work done in Python in 2019 and 2020 to better isolate subinterpreters. Static types are converted to heap types, extension modules are converted to use the new multiphase initialization API (PEP 489), caches, states, singletons and free lists are made per-interpreter, many bugs have been …

Category: cpython Tags:

Hide implementation details from the Python C API

 — 
My cat attacking the Python C API

This article is the history of Python C API discussions over the last 4 years, and the creation of C API projects: pythoncapi website, pythoncapi_compat.h header file and HPy (new clean C API). More and more people are aware of issues caused by the C API and are working …

Category: cpython Tags:

Leaks discovered by subinterpreters

 — 

This article is about old reference leaks discovered or caused by the work on isolating subinterpreters: leaks in 6 different modules (gc, _weakref, _abc, _signal, _ast and _thread).

_thread GC bug

Refleaks buildbot failures

With my work on isolating subinterpreters, old bugs about Python objects leaked at Python exit are suddenly becoming blocker …

Category: cpython Tags:

GIL bugfixes for daemon threads in Python 3.9

 — 
`#CoronaMaison by Boulet

My previous article Daemon threads and the Python finalization in Python 3.2 and 3.3 introduces issues caused by daemon threads in the Python finalization and past changes to make them work.

This article is about bugfixes of the infamous GIL (Global Interpreter Lock) in Python 3.9, between …

Category: cpython Tags:

© Victor Stinner 2016

Powered by Pelican