Free T(h)r(e)ading: A Trading Systems Journey Beyond the GIL

Tim Kreitner

Programming & Software Engineering & Testing
Python Skill Intermediate
Domain Expertise None

The release of Python 3.13 with experimental free-threaded mode (PEP 703) represents a fundamental shift in Python's concurrency model. For decades, the Global Interpreter Lock has dictated how we write concurrent Python code, pushing developers toward async/await patterns for I/O-bound workloads and multiprocessing for CPU-bound tasks. But what happens when we remove that constraint?

We designed a research experiment to answer this question empirically: take a production trading algorithm built on asyncio, migrate it to free threading, and measure everything. Trading systems make ideal subjects for this research—they're latency-sensitive, handle multiple concurrent data streams, perform both I/O and CPU-bound operations, and have clear, quantifiable performance metrics.

This talk presents our complete research journey, from initial hypothesis to validated conclusions, sharing both our methodology and findings.

Detailed Outline:

  1. Research Question & Motivation (3 minutes)

The research question: can a trading algorithm benefit from true parallelism? Why trading systems make ideal experimental subjects Initial hypotheses about performance characteristics Baseline system: async architecture and performance profile

  1. Experimental Design (4 minutes)

Migration approach Benchmarking framework Workload simulation Control variables and isolation of I/O vs. CPU-bound operations

  1. Migration Journey (5 minutes)

Architectural transformation Key refactoring patterns and synchronization strategies Thread safety challenges Library ecosystem compatibility findings

  1. Results & Discoveries (8 minutes)

Performance data: latency, throughput, and resource utilization Workload analysis: where free threading won, where async remained competitive Visual data presentation: charts and comparative analysis

  1. Practical Implications (4 minutes)

Decision framework: when to choose free threading over async Migration best practices and lessons learned Production readiness assessment What this means for Python's concurrent future

  1. Q&A (5 minutes)

Prerequisites - This talk assumes attendees have:

  • Strong understanding of Python's concurrency models (asyncio, threading, multiprocessing)
  • Familiarity with the GIL and its implications
  • Basic understanding of systems programming concepts (thread safety, synchronization)

Tim Kreitner

Tim Kreitner is a Senior Software Engineer at Vattenfall Energy Trading GmbH in Hamburg, Germany. With a background in Mechanical and Computational Engineering, Tim transitioned into the field of finance, leveraging various programming languages.

At Vattenfall, Tim develops Algorithmic Trading Infrastructure applications. Including Order Routers, Market Data Servers, Exchange connections.