Black Friday deals: AI courses, full course library, and the book.

Free-Threaded Python

Episode #570, published Wed, Nov 25, 2026, recorded Mon, Nov 2, 2026
0:00
01:01:49
It's BLACK FRIDAY at Talk Python
Get the Black Friday deals
NumPy already releases the GIL. So threads should already pay off for your NumPy code, right? Christopher Ariza tested that. He summed the rows of a 10,000 by 10,000 array on Python 3.14. Sequential took 360 milliseconds. A thread pool took 373, slower than doing nothing. The same code on free-threaded Python 3.14t took 83.7 milliseconds. Free-threaded Python is officially supported as of 3.14. The GIL isn’t gone, though. It’s a zombie. Import one compiled package that hasn’t opted in, psycopg2 for example, and the GIL comes back for your entire process. You get a warning, not an error.

Chris is the creator of StaticFrame and its C extension library ArrayKit. We dig into when threads beat plain NumPy, how to tell if you’re actually running free-threaded, and conditional-futures, his drop-in thread pool that stops your code from getting slower when the GIL wakes back up.

Watch this episode on YouTube
Play on YouTube
Watch the live stream version

Episode Deep Dive

Guest Introduction and Background

Christopher Ariza is the creator of StaticFrame, an immutable DataFrame library for Python, and of ArrayKit, the C extension library that supplies much of StaticFrame's performance. Chris spent 14 years at Research Affiliates, a finance firm in Newport Beach, starting as a software engineer, moving up to lead teams, and ultimately serving as Chief Technology Officer. After a year and a half working on the sale of the company's index business and its restructuring, Chris is leaving the firm at the end of the year and has new projects planned for the new year.

Chris is also the author of Fetter, a Rust-based scanner that finds every Python environment on a machine and reports installed packages with known vulnerabilities. Chris is a regular speaker at regional Python conferences, and this episode grew out of the PyBay talk "Getting Started with Free-Threaded Python Using NumPy". Chris was last on Talk Python for episode 204, which covered StaticFrame. Since then StaticFrame has grown "even more static", with a lot of work on static typing and TypeVarTuple.


What to Know If You're New to Python

This episode is about running Python code on many CPU cores at once, so it helps to have a rough picture of what threads are and why Python historically could not use them for number crunching. Here are the ideas that come up again and again in the conversation.

  • The GIL (Global Interpreter Lock): A lock inside standard CPython that lets only one thread run Python code at a time. It is the reason adding threads to CPU-heavy Python code has traditionally made it no faster, and often slower.
  • Free-threaded Python: A separate build of CPython (for example python3.14t) where the GIL is disabled so threads can truly run in parallel. It is officially supported as of Python 3.14, but you have to install it on purpose.
  • Reference counting: Python tracks how many names point at every object, and updates that count constantly. Keeping those counts correct across threads was a big part of why the GIL existed, and solving it was the hard part of removing it.
  • C extensions and wheels: Many popular packages (NumPy, database drivers, and more) contain compiled code shipped as prebuilt files called wheels. Each compiled package has to opt in to free-threaded Python, and one that has not can switch the GIL back on for your whole program.
  • Thread pools and concurrent.futures: The standard library's simple way to hand a batch of work to several threads or processes. Chris's conditional-futures library, a centerpiece of the episode, is a drop-in variation on this idea.

Key Points and Takeaways

1. NumPy releasing the GIL was never enough; free-threaded Python is what makes threads pay off

The central question of the episode: NumPy already releases the GIL and already uses SIMD, so shouldn't threads already help NumPy code? Chris tested it and the answer on standard Python is no. In the headline example from the talk, row-wise work on a 10,000 by 10,000 array took 360 milliseconds sequentially and 373 milliseconds with a thread pool on Python 3.14, then 83.7 milliseconds on free-threaded Python 3.14t. Chris first tried free threading on StaticFrame, which already had built-in options for multi-threaded and multi-processed function application, and saw operations take half the time or less with no code changes. The same standard library threading tools that never quite delivered simply started working the way everyone had hoped. The surprise for Chris was that for some array shapes, threads on free-threaded Python can beat native NumPy at something as optimized as summing rows.

2. The GIL is a zombie: one incompatible import brings it back for the whole process

In the free-threaded build, the GIL is not removed. It is disabled, and it can come back. If you import any compiled wheel that has not declared it can run safely without the GIL, Python re-enables the GIL dynamically for the entire process. The example from Chris's "Raising the Dead" slide is psycopg2, the hugely popular PostgreSQL adapter: check the GIL, it is off, import psycopg2, and it is on. You get a RuntimeWarning, not an error. This can happen at any point in a program's life, for example through an import buried inside a function that runs late. Michael said this was the biggest thing learned from the talk, and Chris called it the number one thing to watch for when depending on free threading.

3. Threaded code under the GIL is not just "no faster", it can be much slower

A point both Michael and Chris stressed: when the GIL comes back, you do not simply lose your speedup. Code written for many threads, running with the GIL on, pays for all the thread overhead and context switching with no extra compute to show for it. The result can be materially worse than never threading at all. As Michael put it, the program is using more of your machine and going slower. That raises the stakes for anyone writing code that counts on free threading, because the same code can be an order of magnitude faster or noticeably slower depending on an interpreter state you may not control. The warning message does offer an escape hatch, PYTHON_GIL=0, which keeps the GIL off "at your own risk". Chris noted that this ignores the compatibility declaration but makes no promise about thread safety in that package.

4. conditional-futures: a drop-in thread pool that adapts to the GIL

Chris's answer to the zombie GIL is conditional-futures and its ConditionalThreadPoolExecutor. It is a subclass of the standard thread pool executor, type compatible, used as a context manager with the same interface. Before each call it checks whether the GIL is enabled. If the GIL is off, it uses real threads. If the GIL is on, it runs the same work serially in the parent thread without spawning any new threads at all. That lets you write code as if free threading is always available and have it degrade gracefully instead of getting slower. It matters most for library authors, who cannot know which Python build their users run or which wheel a user might import. Chris also loves the name: your futures really are conditional.

5. One benchmark is not enough: tall, square, and wide arrays behave differently

Chris has long been frustrated by performance claims shown on a single arbitrary DataFrame. Systematic testing shows that shape (tall, square, or wide) and data types (floats, integers, strings) change the results a lot, so Chris always varies the fixtures across those shapes. For this study the operation was row-wise function application over about 100 million elements, a common pattern in financial modeling. For a plain row sum(), threads made every shape worse with the GIL. Without the GIL, tall and square arrays still got worse, but wide arrays, where each row is more work and there are fewer rows, dropped to roughly two thirds of the time. That lines up with Michael's short version: if each thread does not get enough work, the overhead swamps the benefit.

6. More Python-level work per row means bigger wins

The second example in the talk does a little more per row: find the even numbers, which produces a Boolean array, then use that array to select a subset from another array. Most of the work is still inside NumPy, but intermediate Python objects come back along the way. That extra overhead at the Python layer is enough to tip the scales. With the GIL removed, square and wide arrays delivered a true order of magnitude improvement, which Chris called the gold standard. Chris had seen hints of this five to ten years ago, when carefully tuned cases of multi-threaded NumPy would occasionally win under the GIL, but they were hard to find. On free-threaded Python the bar for a real benefit is much lower, and most people doing real work per row will get there quickly.

7. Getting free-threaded Python, and knowing whether you are actually running it

Chris thinks most people have not tried free-threaded Python yet, largely because it is a separate binary you must download, build, or install. The convention is a trailing t, as in python3.14t, but it is not uniform: a virtual environment created from a free-threaded Python, or a local build, gives you a binary without the t. The naming is also inconsistent across tools, with "free-threaded", "free-threading", "nogil", and "3.14t" all in use. Michael showed that uv makes installing easy with uv python install 3.15t, and uv python list shows which builds you have. At runtime, sys._is_gil_enabled() tells you the truth, though it still carries a leading underscore. Chris's strong belief is that the two-binary situation goes away and free-threaded Python eventually becomes just Python.

8. How we got here: reference counting, the Gilectomy, and PEP 703

When Chris first heard about free threading, the news was all bad: everything was slower, and early on that was true. Michael described it as the white whale of the core developers, from Larry Hastings' years of Gilectomy work to Sam Gross finally cracking it around the 3.12 timeframe. For a long time the core team's position was that any design that dramatically slowed single-threaded Python, the most common case, would not be accepted. The hard problem is reference counting: every object lives on the heap and nearly every operation touches a reference count, which the GIL made safe. Chris credited the core developers with layered solutions to that problem, plus a huge effort to make the standard library and its containers thread safe without giving up performance. Free threading arrived in 3.13 on a conditional basis under PEP 703 and has now made it through that probationary period.

9. Immortal and immutable objects are part of the solution

Chris shared a favorite surprise from writing C extensions: having to increment the reference count of None. That is no longer necessary because None is now immortal. It is allocated once and shared for the life of the process, so nobody ever has to touch its count. Broadening the set of immortal objects is one of the changes that helped free threading work. Michael connected this to pre-allocated small integers and the flyweight pattern, which only works because those objects cannot change. Chris wondered about being able to declare your own objects immortal, which is not available yet. Both expect immutability to get far more attention as Python moves into a multi-threaded world, and Chris is delighted that the long-awaited frozendict arrives in Python 3.15.

10. Porting a C extension: opt in explicitly, and brace for twice the wheels

One of Chris's first tasks was upgrading ArrayKit to support free-threaded Python. Every C extension package has to be rebuilt for the free-threaded build and must explicitly opt in. The practical cost showed up in continuous integration: Chris counted 12 wheels across the supported Python versions and three platforms, and free threading doubled that to 24. It all runs in a GitHub Action, but it is a lot of binaries to manage. The good news is that Python 3.15 brings a stable ABI for free-threaded builds. Chris has not tried it yet, but understands it will allow one wheel to work on both free-threaded and standard Python.

11. It is an ecosystem challenge now: 218 of the top 360 packages are ready

Michael's framing was that free threading is no longer a Python runtime problem, it is an ecosystem problem. Two trackers came up: the Quansight free-threading guide with its compatibility tracker, and Hugo van Kemenade's free-threaded wheels page, which showed 218 of the 360 top packages with free-threaded support. Chris pointed out this follows the pattern set during the Python 3 migration and called the number very good for what is still a minority interest. Pure Python packages load fine and leave the GIL off, though they may not be thread safe. The risk is compiled packages that have not opted in. Michael counted more than 270 packages in one web app's virtual environment and doubted they were all green, which gives the transition a little bit of a Python 2 to 3 feel.

12. Compatible does not mean thread safe: lean on immutability and test for it

Michael raised a real worry. Developers from C++ and C# backgrounds habitually think about shared data, race conditions, and deadlocks, and that habit has not been common in Python. A package whose builds and CI pass on free-threaded Python is not the same thing as a package free of threading bugs. Chris's advice is to use immutable data structures and avoid mutating things in place while multi-threading, which sidesteps a huge share of the problems that locks exist to solve. If you do land in a complicated spot, the standard library has had the locking tools for a decade or more. Chris agreed that most Python projects have not had multi-threaded scenarios in their CI test batteries. Michael suggested AI agents could help by generating a barrage of parallel stress tests.

13. Lightweight threads open up small and medium work units, especially inside libraries

Before free threading, the escape hatches for parallel work were running on a GPU, multiprocessing, writing the hot path in C, or writing it in Rust, where the threading story is excellent. Multiprocessing suits big, heavy jobs, and library authors rarely built it in because a library cannot assume how many cores or how much work a user has. Chris's excitement is that Python now has lightweight, true thread concurrency in the language, including for work on heavy Python objects. A whole range of small to mid-sized work units can now benefit. Michael expects many people will get free threading indirectly, by calling an ordinary function in a library that parallelizes internally. On the web side, Chris suggested checking your web server's threading story first and building isolated tests to see whether you really get better performance. Chris also mentioned that subinterpreters, the other concurrency escape hatch, now share the same concurrent.futures pool interface.

14. AI agents write serial code first, so ask for concurrency

Chris has found coding agents to be "serial first", in Python and even in Rust, a language with excellent multi-threading support. The classic Python case is downloading a bunch of files in a loop, where threads have always worked well. Select that code, ask the agent to make it threaded, and it will, but you have to read the code and notice it is serial before you can ask. In Rust, Rayon offers high-level tools to make the iterations of a loop run across threads, and agents still do not reach for it unless prodded. This fit a wider theme from early in the episode: every close read of agent-written code turns up something Chris can materially improve, and the best results today still come with human engagement and insight. Michael added the fair warning that threading is great most of the time, right up until the program stops responding at zero CPU.

15. Fewer dependencies help with both free threading and supply chain risk

A tangent with real substance: a web app with 270 packages has 270 chances for something that is not free-threading ready. Michael argued for vendoring small pieces of functionality or having an agent write 20 lines of code rather than adding a library that drags in four more. Chris feels the same pull, noting you lose some reuse but avoid a lot of dependency problems. You can tell an agent to make your own 20 lines thread safe, but you cannot easily do that for a third-level transitive dependency. It also reduces supply chain exposure. As CTO, Chris found Python dependency management was the least locked-down part of an otherwise strong security setup, and that tools like JFrog Artifactory do not stop a developer from installing packages on another network. That led Chris to build Fetter, which scans every Python and every site-packages directory on a system and reports packages with CVEs, so one search answers whether anyone in the organization has a compromised package.

16. PyBay and the value of regional Python conferences

Michael and Chris met up at PyBay, where both gave talks, and that is how this episode came about. Chris has been attending more of the smaller conferences lately, including PyTexas in Austin and PyBeach in Santa Monica, and described PyBay as a bit bigger with two tracks, very well organized, and strong on talk quality. Michael said the talk taught quite a bit even to someone already familiar with free threading. Chris's slides and code are on GitHub now, and the talks were recorded, so the video should follow. Michael recommended the conference to anyone in the area and said plans for next year are already underway.


Interesting Quotes and Stories

"I nearly fell out of my chair when I saw an operation take half the time or less just out of the box without me changing any code." -- Christopher Ariza

"The GIL is a zombie right now. In the free-threaded binary of Python, the GIL is not removed. It is disabled." -- Christopher Ariza

"My strong belief is that this is all going to go away. And eventually, free-threaded Python is just going to be Python." -- Christopher Ariza

"Use immutable data structures and don't try to mutate things in place while you're doing your multi-threading and you just avoid a ton of the problems." -- Christopher Ariza

"If I can go an order of magnitude faster, I have every reason to be happy." -- Christopher Ariza

"The concurrent futures library in Python is just gorgeous. I mean, it's one of my favorite Python pieces." -- Christopher Ariza

"For the first time in Python, we now have lightweight true thread concurrency." -- Christopher Ariza

"Yes, async can do a lot. But if you have performant lightweight threads, they can do more." -- Christopher Ariza

"People say, we don't have to worry about pointers in Python. Well, actually, everything is a pointer in Python." -- Michael Kennedy

"Honestly, it's an ecosystem challenge, not a Python runtime challenge now." -- Michael Kennedy

"We can make our libraries 30% faster, and that's a lot to celebrate. But if we can make it run actually on 20 cores, that's more than 30%." -- Michael Kennedy

The reference count of None. One of Chris's most surprising lessons from writing C extensions was having to increment the reference count of None. Chris's reaction at the time was "why would I have to increment the reference count of None?" Today you do not, because None is immortal.

From 12 wheels to 24. Adding free-threaded support to ArrayKit meant building a second wheel for every Python version and platform combination, doubling the CI output from 12 wheels to 24. Chris was relieved it all lives in a GitHub Action.

Saying thanks to the agent. After a long and productive Claude Code session, Chris has started signing off with something like "Excellent work today. We really accomplished a lot." The reply usually says thanks and then points back to the specific insights Chris contributed during the session. Michael's version of the same story: getting tired of being called "the user" in the third person by the only thing talked to all day, and asking to be addressed by name.

"Are threads working yet?" Because concurrent.futures offers one interface for threads and processes, Chris spent a decade flipping between the two in StaticFrame and asking the same question each time. With free-threaded Python the answer finally changed.


Key Definitions and Terms

  • GIL (Global Interpreter Lock): The interpreter-wide lock in standard CPython that allows only one thread to execute Python code at a time. A large part of its job was making reference count changes atomic.
  • Free-threaded Python: The CPython build with the GIL disabled, conventionally named with a trailing t such as python3.14t. Experimental in 3.13 and supported as of 3.14.
  • Zombie GIL: Chris's description of the current state of affairs. The GIL still exists in the free-threaded build and comes back to life when an incompatible compiled module is imported.
  • Reference counting: CPython's primary memory management technique. Each object stores a count of references to it, and the object is freed when that count reaches zero.
  • Immortal objects: Objects such as None whose reference counts are never modified and which live for the life of the process. They need no reference count coordination between threads.
  • Flyweight pattern: Pre-allocating shared immutable objects and pointing to them instead of creating new ones. Michael used CPython's small integer cache as the example.
  • C extension: A Python package component written in C (or another compiled language) against CPython's C API. Each one must be rebuilt for, and opt in to, free-threaded Python.
  • Wheel: Python's prebuilt binary package format. Compiled packages publish separate wheels per Python version and platform, and currently per free-threaded build as well.
  • Stable ABI: A restricted binary interface that lets one compiled extension work across multiple Python versions. Python 3.15 adds a stable ABI for free-threaded builds.
  • Thread safety: The property that code behaves correctly when several threads use it at once. Loading without re-enabling the GIL does not prove a package is thread safe.
  • Race condition and deadlock: The two classic threading bugs. A race condition is a wrong result that depends on thread timing. A deadlock is threads waiting on each other forever, which shows up as a hung program using zero CPU.
  • SIMD: Single instruction, multiple data. CPU instructions that process several values at once, one of the ways NumPy is already fast on a single core.
  • concurrent.futures: The standard library module providing ThreadPoolExecutor and ProcessPoolExecutor behind one shared interface.
  • ConditionalThreadPoolExecutor: The executor in conditional-futures that uses threads when the GIL is off and runs serially in the parent thread when it is on.
  • Subinterpreters: Multiple isolated Python interpreters within one process, mentioned by Chris as the other escape hatch for concurrency.
  • Row-wise function application: Applying a function to each row of a table or 2D array to derive a new value. This is the workload Chris benchmarked.
  • frozendict: The immutable dictionary type arriving in Python 3.15, which Chris has been waiting on for years.

Learning Resources

If this episode made you want to really understand threads, memory, and native performance in Python, here are a few courses from Talk Python Training that go deeper on exactly those topics.

  • Async Techniques and Examples in Python: Covers the full spectrum of Python's parallel APIs, including threads, multiprocessing, asyncio, and thread safety. It is the direct follow-up to this episode's discussion of thread pools, locks, and race conditions.
  • Python Memory Management and Tips: Explains reference counting and garbage collection with concrete code. That is the machinery at the heart of why the GIL existed and why removing it was so hard.
  • Up and Running with Rust: A Python developer's fast track to Rust, ending with a compiled extension you can import from Python. A good fit if the talk of Rust extensions, Rayon, and Fetter made you curious.

Overall Takeaway

For most of Python's history, "use threads to go faster" came with an asterisk the size of the GIL. This episode is about that asterisk finally shrinking. Chris took the most skeptical test case available, NumPy code that is already compiled, already vectorized, and already releasing the GIL, and showed that free-threaded Python can still make it faster, sometimes by an order of magnitude, using the same standard library thread pool we have had for years.

The honest part of the story matters just as much. The GIL is a zombie, not a corpse. A single wheel that has not opted in can bring it back with nothing more than a warning, and threaded code under a revived GIL can be slower than code that never used threads at all. So measure across tall, square, and wide data instead of trusting one benchmark, check sys._is_gil_enabled() rather than assuming, keep your data immutable where you can, and consider a tool like conditional-futures so your code degrades gracefully.

Python has spent years chasing 10, 20, and 30 percent speedups, and those are worth celebrating. Running across every core in the machine is a different kind of gain. Free-threaded Python is one uv python install 3.14t away, so pick a real workload, try it, and see what your own numbers say.

Guest
Christopher Ariza: github.com

GIL Guard project: mkennedy.codes
chameleon-rs: mkennedy.codes
diskcache-oxide: mkennedy.codes

Black Friday at Talk Python: talkpython.fm/black-friday

episode 204: talkpython.fm
Fetter: fetter.io
PyBay 2026: pybay.org
StaticFrame: github.com
Free-threaded row-wise apply: static-frame.readthedocs.io
Getting Started with Free-Threaded Python Using NumPy: github.com
Free-threaded Python: docs.python.org
abi3t: peps.python.org
TonIO: talkpython.fm
did a whole course: training.talkpython.fm
psycopg2: pypi.org
ArrayKit: github.com
217 of the top 360: hugovk.dev
Quansights free-threading guide: py-free-threading.github.io
conditional-futures: github.com
rayon: github.com

Watch this episode on YouTube: youtube.com
Episode #570 deep-dive: talkpython.fm/570
Episode transcripts: talkpython.fm

Theme Song: Developer Rap
🥁 Served in a Flask 🎸: talkpython.fm/flasksong

---== Don't be a stranger ==---
YouTube: youtube.com/@talkpython

Bluesky: @talkpython.fm
Mastodon: @talkpython@fosstodon.org
X.com: @talkpython

Michael on Bluesky: @mkennedy.codes
Michael on Mastodon: @mkennedy@fosstodon.org
Michael on X.com: @mkennedy

Episode Transcript

Collapse transcript

00:00 NumPy already releases the gill, so threads should already pay off for your NumPy code, right?

00:05 Christopher Orisa tested that. He summed the rows of 10,000 by 10,000 arrays on Python 3.14.

00:13 Sequentially, it took 360 milliseconds.

00:15 A thread pool took 373 milliseconds, slower than doing it in single-threaded mode. The same code on free-threaded Python took 83

00:25 milliseconds.

00:26 Free-threaded Python is now officially supported in Python 3.14, and that's a huge

00:31 opportunity for us.

00:33 But this came as a surprise to me, and it may to you as well. The gil isn't

00:38 actually gone.

00:38 It's a zombie.

00:40 If you import one compiled package that hasn't opted in, for example, at the time of recording,

00:46 Psycho PG2, the gil comes back on for your entire free-threaded process.

00:51 You get a warning, not an error.

00:53 Christopher is the creator of StackFrame and its C extension library, ArrayKit.

00:56 And we dig into when threads beat plain NumPy, how to tell if you're actually running free

01:01 threaded and conditional futures, his drop-in thread pool that stops your code from getting

01:07 slower when you run into a single threaded or gil-based situation.

01:12 This is Talk Python To Me, episode 570, recorded October 13th, 2026.

01:35 Welcome to Talk Python To Me, the number one Python podcast for developers and data scientists.

01:40 This is your host, Michael Kennedy.

01:42 I'm a PSF fellow who's been coding for over 25 years.

01:46 Let's connect on social media.

01:47 You'll find me and Talk Python on Mastodon, Bluesky, and X.

01:51 The social links are all in your show notes.

01:54 You can find over 10 years of past episodes at talkpython.fm.

01:57 And if you want to be part of the show, you can join our recording live streams.

02:01 That's right.

02:02 We live stream the raw uncut version of each episode on YouTube.

02:05 Just visit talkpython.fm/youtube to see the schedule of upcoming events.

02:10 Be sure to subscribe there and press the bell so you'll get notified anytime we're recording.

02:14 It's Black Friday week here at Talk Python.

02:17 The entire library is $50 off with the Everything Bundle.

02:21 And there's a new starter set of courses, four courses, for learning Python in the age of AI.

02:28 And that's only $56.

02:30 The Talk Python in production book is 25% off and membership at Talk Python is 30% off,

02:36 which gets you into our discords and monthly meetups.

02:39 Visit talkpython.fm/Black Friday.

02:42 The sales end December 2nd.

02:44 Thanks for supporting the show.

02:47 I'm really excited about this upcoming conversation with Chris about free threading in Python.

02:51 It's something that he and I both care a lot about.

02:54 And while it's been fine that Python doesn't really have true threading,

02:58 now that we do, it's important that we actually have libraries and tools that actually use it.

03:04 Chris has a bunch of really awesome advice and some great open source libraries

03:08 he's created to help manage free threaded and GIL-based apps that both have to run on the same code base.

03:14 I'm somewhat inspired by his conversation and previous work I was already doing.

03:17 I actually created three new open source projects related to free-threaded Python

03:22 that I just want to give a quick heads up to you all about.

03:24 I would have certainly brought them up during the conversation with Chris,

03:27 but they didn't exist at that time.

03:29 The magic of time-shifting and podcasting.

03:32 The first one is called GilGuard.

03:34 It's a pure Python library that, if included in your app, will alert you and even raise an exception if you want

03:40 if one of your imports turns the Gil back on in free-threaded Python.

03:44 The second one is Chameleon RS, a thread-safe, free-threaded, optimized,

03:48 Rust-based Chameleon template engine.

03:50 And the last one is new, DiskCacheOxide.

03:54 This is the DiskCache library we've discussed previously on the show, rewritten to be, you know it, free-threaded, safe,

04:01 in Rust, highly optimized, so it can take full advantage of free-threaded Python.

04:05 All three of these projects have links in the podcast show notes, so check them out.

04:10 Thanks to Chris for inspiring Gilgard.

04:12 Let's jump into the conversation.

04:14 Chris, welcome back to Talk Python To Me.

04:16 Amazing to have you here.

04:17 Thanks, Michael.

04:18 It's really good to be back.

04:19 Well, more dynamicism, less static frames this time.

04:24 Had you on for static frame last time?

04:25 Yeah, yeah.

04:26 It's been a while.

04:28 The static frame has grown even more static with a lot of work in static typing.

04:34 And TypeVar Tuple last year I was doing a lot of work with.

04:37 So it's even more static.

04:38 But today we can talk about more dynamics.

04:40 Well, we can.

04:42 though I and I know we will.

04:44 However, I do think static things, immutable things actually have a really important place in this topic.

04:50 Yeah, that's right.

04:52 You know, as we move more into a multi-threaded universe in Python, having immutable containers is even more important. And

04:59 so, you know, I've been waiting for Python's immutable frozen dictionary for so many years.

05:05 And finally, we get that with Python 3.15.

05:10 And I think that attention to immutable data structures is really going to become important in Python.

05:15 Yeah, the frozen dict, which is really interesting.

05:17 We get, you know, all this stuff came out October 9th, which is a little later than originally planned.

05:23 But it came out October 9th, which is four days before the recording.

05:27 So for us, even depending on when people listen, but for us, this is a brand new Python 3.15.

05:31 It's amazing.

05:32 Yeah, that's right.

05:33 Tell people quickly about yourself.

05:34 It's been a little while since we've talked on the show.

05:37 And so.

05:38 Sure.

05:39 So I, for 14 years, I've been at Research Affiliates, which is a small finance firm located in Newport Beach.

05:47 I started there as a software engineer and moved my way up to lead some teams and ultimately became the chief technology officer.

05:56 And I held that role for a couple of years.

05:58 This year, the company sold off its index business and has restructured into a new entity.

06:07 That was a big project for me for about a year and a half working on that transaction.

06:12 But that is done.

06:14 And as such, I'll be leaving the firm at the end of the year and we'll be moving on to other endeavors.

06:19 Well, congratulations, I guess.

06:21 And, you know, that's a very long run.

06:23 And it's cool to kind of lead a big group of people working on big projects,

06:27 right?

06:27 the CTO side of things and all that.

06:30 Yeah, exactly.

06:30 I mean, that's what I already miss working with all my AI agents is the camaraderie of working with people and building teams

06:38 and building engagement.

06:40 I can have all my agents do a ton of work, but I miss the banter.

06:44 I miss the shared ideas and the creativity that comes from working with people on all those things.

06:50 But we can get a lot done.

06:52 Yeah, it's just nothing but business, folks.

06:55 Let's go.

06:56 Let's go.

06:58 so for me obviously i've been working on my own for for quite a while i worked it before of course

07:03 but since 2016 it's just been me and my own business and so i totally get what you're saying

07:10 about this like being around people and so on luckily i get to talk to folks like you on the

07:14 show every week which is great but when when the ai stuff came around i actually it was actually a

07:20 little unnerving to me how impersonal and third person it would be like the user has reported the

07:26 is unacceptable.

07:27 We are now refactoring.

07:28 Please stop.

07:30 You're the only thing I talk to all day.

07:32 Don't call me the user in third person. Like Michael, my name is Michael.

07:36 Address me. Right.

07:37 And I got it too. And now it's like, Hey, Michael, we're working on this.

07:40 And then like Michael said, if we want to do that, I'm like, okay, it's a little bit better.

07:44 It's a little bit better.

07:46 That's hilarious.

07:46 Yeah.

07:47 I've just recently I've done this strange thing where after, you know, a huge agent session running hours,

07:53 you know, if I'm really pleased with the work at the end, I'll say something like,

07:57 you know, excellent work today, we really accomplished a lot.

08:00 And the responses I get at from that are just really surprising, because actually, very often what

08:06 I'll find I use Claude Code very often, I'll find that what it says back is,

08:10 it'll say thanks, or I appreciate that, or that's lovely to hear.

08:13 And then it will go on and say, well, actually, your insights were the ones that led to this and this and this. And so it will like instinct,

08:20 I don't know, instinctively is not the right word. It will somehow go to point out where my contributions were in the

08:26 interactions we had had working on that session, which is fascinating. It is fascinating.

08:31 And I know there's, there's two, we're not gonna make this an AI show, but there's two minds around this.

08:38 Well, there's one, obviously, like, stay away from AI.

08:41 I hate it. I want nothing to do with it.

08:42 That's one. But of the people who interact with them, there's the kind that kind of try to treat

08:47 it as a co-worker or a collaborator, which sounds like you and I are kind of in that camp. And other

08:54 people have come up with terms to specifically sort of like diminish it a little bit in a way that

09:00 you don't get connected with. Like clanker is a common term for these, right? Like I yelled at

09:05 the clanker. It's like, you don't love your clanker. It's a thing in the corner.

09:08 Clankety clank is a bad noise.

09:10 It's like uncomfortable.

09:12 I don't know. It's just, we live in a weird time.

09:14 I mean, I think I think Clanker is a little bit more derogatory, right?

09:18 Because I look to the Star Wars reference where, you know, Clankers is what they would say before they usually destroyed the robot.

09:25 So it's a little bit more derogatory.

09:28 But yeah, no, I mean, I have, you know, you hear people tell lots of stories about one shot coding things.

09:34 You hear people tell stories about, you know, not even looking at the code anymore.

09:38 And yes, I don't I can't look at all of the code.

09:40 Every time I look at the code, I find things to improve materially.

09:44 Every time I fully understand what's going on, I'm able to provide better feedback,

09:49 better refinements.

09:50 So it's I think the best results for now, right now, come with the human interaction.

09:56 Without that, you get good results, but you can actually get better with engagement.

10:01 And I believe human insight.

10:03 At least for now.

10:05 I'm not in the just like send it and just, you know, the mayor and the accountant and the builders all get together.

10:12 And two weeks later, here's my app.

10:13 Like, I'm not here for that.

10:15 All right.

10:15 So what's next?

10:16 You said you're leaving the firm.

10:18 Are you willing to share your plans?

10:19 Are you going to sit on the beach for a while?

10:21 What's happening?

10:21 Not just yet.

10:22 There will be some time on the beach.

10:24 But I think come new year, I'll have a couple of things that are ready to release and talk about.

10:30 But for now, we're just going to wait and see.

10:34 All right.

10:34 The suspense.

10:35 We've only got a few months.

10:37 The end of the year is not that far away.

10:38 I know.

10:39 I know.

10:39 I know.

10:39 Tell me about it.

10:40 Yeah.

10:41 All right.

10:41 Well, let's get into our main topic.

10:44 And I want to maybe kick it off by way of a quick shout out to PyBay.

10:50 So you and I just met up at PyBay.

10:53 And that's how I knew about this topic and how you're interested in it.

10:56 I mean, I knew pre-threaded Python existed, but I honestly learned quite a bit from your talk.

11:02 And that was the fun.

11:03 What was your thought on PyBay?

11:04 Yeah, PyBay was great.

11:05 You know, in the last couple of years, I've been to a few more of the smaller Python conferences.

11:11 I was at Pi Texas in Austin, which was a really nice conference.

11:16 Pi Beach in Santa Monica last year was also really great.

11:20 Pi Bay, a little bit bigger, right?

11:22 It's a two-track conference, which makes it just a little bit bigger than some of these other ones.

11:27 And yeah, very well organized.

11:31 Much appreciation to the organizers for all the hard work to get it going.

11:35 And yeah, the quality of talks I thought was really good.

11:38 Yeah, I did too.

11:38 I actually got a lot out of the talks.

11:40 I thought the conference was great.

11:41 So recommend people check it out if they're either in the area or they feel like going next year.

11:47 I hear there's already plans for next year. So that'll be great.

11:51 Now your talk, your talk was interesting. I feel like first your delivery was great,

11:55 but I feel like your delivery also kind of embodied the topic because you didn't have a

12:00 super long time to speak.

12:02 And so you had a lot to cover. So it kind of went quick and like, Right.

12:06 So I feel like, hey, we're picking up speed.

12:09 We're doing free threading. This is like parallelism. Let's go. Let's go. Let's go. You know?

12:13 Yeah, that's true.

12:15 A 30 minute window can be a 25 minute talk or a 20 minute talk.

12:19 And at the 20 end, it gets a little tight.

12:22 Oh, it definitely does.

12:23 You know, my talk was fine in terms of I had a little bit of a gap at the

12:28 end, but if it was 20 minutes, then definitely it would have been flying.

12:31 All right. So your talk, you actually have the slides on GitHub and I'll be sure to link to them.

12:37 Well, getting started with free threaded Python using NumPy.

12:41 And that's, that's an interesting angle.

12:43 I think all the stuff, all the video, all the talks were recorded and the videos will be released.

12:48 I don't know the timeframe for that, but they have been traditionally.

12:51 So, and I know there were cameras there because we weren't allowed to walk

12:55 around that much. We like, you stay here. The camera's focused here.

12:57 Like, okay.

13:00 But so eventually, actually, maybe by the time people listen to this, we'll see if the talk is out a link to it.

13:05 But right now, about the slides and we've got your GitHub repo, which is pretty cool.

13:10 Yeah.

13:10 So tell us what was the premise of the talk in the using NumPy.

13:15 Tell us what's that.

13:16 Sure.

13:17 Well, obviously, when I started to hear, well, then when I first started to hear about free threaded Python,

13:23 I only heard bad news.

13:25 I heard it was slower.

13:27 Everything is slower.

13:28 And that actually was the case, I think, three years ago or longer when they first started experimenting at the level of the CPython core team with free threaded Python.

13:39 So I came away thinking, oh, you know, that's unfortunate.

13:43 This is going to be bad.

13:45 Then I started to hear a bit more positive things.

13:48 And I think it was early last year or the fall of the previous year with Python 3.14 out,

13:58 I decided it was time to experiment with this.

14:02 And the first place I looked was, of course, in Static Frame, a data frame library,

14:09 and where I had already built in the ability to use multithreading and multiprocessing very easily whenever you do operations like apply a function to rows or columns.

14:21 So I'd already built in the functionality to do that.

14:26 And so I was eager to see, well, what happens when I try free-threaded Python with this?

14:30 Am I going to have to change things?

14:31 Is it going to work?

14:32 And I just started it with free threaded Python and everything just worked and everything

14:38 was just faster.

14:39 And I nearly fell out of my chair when I saw an operation take half the time or less just

14:46 out of the box without me changing any code.

14:49 And under the hood, it was using the standard library utilities for free for threading.

14:53 I assumed that we were going to have to change things with free threaded,

14:56 but we didn't.

14:57 They just actually work the way we always hoped they would.

14:59 So that was my start working with large data frames.

15:03 But then I was like, well, what about with NumPy?

15:05 Like NumPy is already super fast.

15:07 It already is releasing the gil.

15:09 It's already using SIMD operations to go as fast as possible.

15:14 Is it possible that with free-threaded Python, we could do the summing of rows,

15:20 a built-in NumPy operation that's already super fast?

15:24 Could we do that faster with threads?

15:26 And you can't for every shape, But for some shapes of two-dimensional arrays,

15:31 you can.

15:32 And that just blew my mind that we were actually able to go faster than native NumPy with threads.

15:39 Yeah, you have a bunch of graphs and I'm sure we'll get to them and talk about them a bit.

15:43 But your slides that we're linking to certainly have graphs.

15:46 And maybe the short version before we get to there is if you don't give enough work to each thread,

15:51 then the overhead overwhelms any advantage you get, right?

15:55 Yeah, that's right.

15:56 But for most folks doing real work, they're going to get there pretty quick.

16:01 Like using NumPy sum on a row is extraordinarily fast.

16:06 Threads are rarely going to help with that.

16:09 But as soon as we start doing more work with each row, as you said, the barrier is much

16:14 lower now to actually get real meaningful performance benefits by using multithreading.

16:19 You're right.

16:19 Free threading had a bit of a bumpy road.

16:23 It's been kind of the white whale of the core developers in a sense, you know?

16:28 Yeah.

16:29 Like always chasing it, never quite able to get there, risking your life to do it or whatever.

16:34 I mean, maybe that's a bit dramatic.

16:35 But there was a lot of work done and a ton of engineering effort put into trying to somehow free things from the GIL.

16:44 You know, Larry Hastings is famous for his years of gillectomy work and reports at the conferences and things like that.

16:51 And then Sam Gross from Meta and the Cinder team finally cracked it around 3.12 timeframe

16:58 and started seeing if we could get it into Python proper.

17:01 Yeah, it's a really challenging problem.

17:04 And I know there's many challenges.

17:07 But to me, the one that stands out is reference counting.

17:11 Reference counting is obviously so important to how Python works and how it gets its excellent

17:16 dynamic behavior.

17:17 And as I understand, a large part of the reason the GIL was there was to make reference count mutations on pi objects atomic using a lock on the interpreter.

17:30 Now, that lock served other purposes, but reference counting was a really critical one.

17:34 And when you look at how they've solved the problem now, it's quite extraordinary because

17:40 there's multiple solutions and multiple layers of solutions really to handle the handling

17:46 reference counts in the face of multi-threaded concurrency.

17:49 Yeah, you're right.

17:49 And one of the things that was the big problem was all the solutions that said, well,

17:54 let's try to enable threading all hinged around this reference counting idea.

18:00 And so it's like, well, we could bring four threads.

18:02 And if we brought four threads, we can actually make it two times as fast.

18:05 But the single-threaded case actually is 40% slower, which is why we need four threads instead of two or whatever.

18:12 And for a long time, the position of the core devs, pretty rightly so, I think,

18:17 was if you're going to do a solution that's going to dramatically slow down Python,

18:21 its most common use case, which is single-threaded, we're not going to do it, right?

18:26 Right.

18:26 So I don't know how many people out there really day-to-day think about the reference counting side.

18:32 What that means is every single interaction with anything has to go and increment a value.

18:39 If I create the number seven, and seven's a little special.

18:41 If I create the number 700, if I create the string Chris, if I create a new customer,

18:47 all of these things are PyObject things out on the heap, right?

18:50 People say, we don't have to worry about pointers in Python.

18:52 Well, like actually everything is a pointer in Python.

18:55 Like literally even numbers and stuff that normally wouldn't be are pointers.

18:59 Any interaction like x equals 7, that has to go and increment the count on that pi object.

19:05 And if you say y equals x, you got to go and increment it on that x thing again,

19:10 right?

19:11 It's just every little step of anything happening has to work with this reference counting.

19:15 And that's where the challenge really got to be.

19:18 So pretty amazing that they cracked that.

19:20 Yeah, that's right.

19:20 If you take some time to try to write your own Python C extensions or study some Python C

19:26 extension code, the challenge of doing Python reference counting obviously really becomes

19:33 front and center.

19:34 One of my most surprising things I learned in writing Python C extensions was that

19:38 I had to increment the reference count of none.

19:40 I was like, what?

19:41 Why would I have to increment the reference count of none?

19:45 Well, you don't anymore because it's immortal.

19:47 Because it's immortal. So you don't need to anymore. And that's also one of the changes they made is

19:52 increasing and broadening the number of immortal objects that are there.

19:57 So that something like none, we never have to touch its reference count.

20:00 It's allocated once and it's just shared over the life of the process, which makes a lot of sense.

20:05 But yeah, I mean, most Python C, a huge part of Python C extension code is reference count management.

20:12 And your comment on none and it being immortal.

20:15 And so that goes back to our opening section that was static and immutable objects.

20:20 If they're immutable, and especially if they're going to be around forever,

20:23 then why should we worry about its reference counting?

20:26 Because it's just life of the process, right?

20:28 Yeah, that's right.

20:30 And it makes you think, well, what if we could actually declare our own objects to be immutable?

20:36 That's not available yet.

20:38 No, not yet.

20:39 Yeah, and that's the reason I said, wait, 7 is special.

20:42 Because even some of the numbers, it's negative 5 to 255 pre-allocated the runtime.

20:48 And they also, when you say the number seven, at least as a literal seven,

20:53 not like six plus one or whatever, it refers back to that same seven instead of a new seven,

20:58 right?

20:58 Right, right.

20:59 It uses the so-called flyweight pattern where you pre-allocate and just point at things.

21:03 And you can do that because they're immutable, right?

21:05 So I think this immutability story is going to get more attention as we start to work our way into multithreading.

21:11 Yeah, yeah, that's right.

21:12 Very interesting.

21:13 Another thing, big deal.

21:14 So we have over here in 3.15, so this is like four days old, we now have a stable ABI for three-threaded builds, which is kind of interesting.

21:23 Yes.

21:24 So a huge part of StaticFrame's performance comes from a C extension library called ArrayKit.

21:32 And that was one of my first tasks was to upgrade that C extension library to support free-threaded Python.

21:38 So all C extension packages need to be explicitly rebuilt for free threaded Python and explicitly opt into that behavior.

21:50 So that was one of the first things I set out to do.

21:52 But then I realized that in my continuous integration, I was going to need to create twice as many wheels.

21:59 So I support Python 3.10 to 3.14, soon to be 3.15.

22:04 so I have four python versions three platforms that's 12 wheels and then with free threaded we

22:11 now have 24 wheels and uh I'm like okay well you know luckily this is all in a in a GitHub action

22:19 I'm not too worried but this is a lot of binaries to deal with so um as I understand I haven't played

22:24 with this yet but the stable abi for three threaded builds will enable us to have one wheel

22:30 that works both on free-threaded and non-free-threaded Python, which really is a positive direction.

22:36 Yeah, that's great.

22:38 So basically how C extensions interact with the Python runtime and whether it's threaded one or the not-threaded one.

22:45 Yeah.

22:45 Okay, so let's talk about getting free-threaded Python.

22:50 We've got uv, which has absolutely made life easier, right?

22:53 For sure.

22:54 But if I just go, somehow I have Python, I have the word Python, something comes up.

22:58 Maybe I got to type Python 3, depending on how I installed it.

23:01 Would I import free threading?

23:03 Like, you know, how does it work?

23:05 Yeah, I mean, this is a bit of a challenge right now.

23:08 And it's one of the things I kind of pointed out in my talk because it's very easy to be confused about this aspect.

23:15 And this is why I think most people actually haven't tried free threaded Python yet, I would say is probably true.

23:23 And it's because as of now, it's a separate binary.

23:26 There's two versions of the binary and you have to either download or build or install

23:31 different Python.

23:32 The convention is, though not entirely uniform, that there will be a little T at the end of

23:38 your Python 314 or soon to be Python 315 T.

23:43 So once you download a binary or build your own, the best way to reference this is with

23:49 a binary that has that little T at the end.

23:52 But to make things very confusing, if you create a virtual environment with a free-threaded version of Python or you compile your own locally,

24:01 you're going to get a version of Python that doesn't have that T on the binary.

24:06 And so it's very easy to get confused about what's going on here.

24:11 And this would be unsustainable, I think, in the long term.

24:14 But my strong belief is that this is all going to go away and eventually free-threaded Python is just going to be Python.

24:21 I agree.

24:22 I think the way that free-threaded Python came into Python, maybe I just haven't paid

24:28 enough attention, but I've never seen anything like this.

24:30 And if it happened before, it's just, like I said, it didn't catch my attention.

24:34 In 3.13, it was like, well, there's this free-threaded thing.

24:38 We accept it.

24:39 I think it was at 7.08, I don't know, something like that.

24:42 7.03.

24:43 Anyway, we accept it conditionally.

24:45 We'll try it this year, but we reserve the right to eject it back out of Python.

24:50 And I'm like, what?

24:52 that is crazy.

24:53 And moreover, I think this is where this all came from.

24:56 It was like you described, you got to get a separate build of Python.

25:02 Like normal Python doesn't have, it has the guild, doesn't have that free threaded Python capability.

25:07 So yeah, you really got to do a lot of work. I threw up here onto the screen,

25:11 my uv Python list --manage Python about what I got installed.

25:16 and I've got 3.15 installed, but apparently I've not yet installed Python 3.15 free-threaded,

25:22 but I do have the free-threaded one for 14, right?

25:25 So I guess for people out there, if they want to install it, obviously they have uv because it's 2026.

25:31 So uv Python install 3.15t is all you got to write, and then boom, you have it.

25:36 Yeah, it cracks me up because there it says free-threaded.

25:40 Different packages call it free-threading.

25:43 Some call it no gill, like the app, DeviantUbuntu app is no GIL.

25:50 And some just call it 314T.

25:53 So it's just, it's kind of a mess right now.

25:55 It is a mess, but it's gotten to, it's officially accepted.

25:59 You know, it's made it through its probationary period of 313 or whatever it was.

26:05 And now it's here and it's just a matter of working well with it, make it go faster.

26:10 Honestly, it's an ecosystem challenge, not a Python runtime challenge now.

26:14 Yeah, so I think a lot of the work of the CPython development over the last couple of years has been making the standard library thread safe and making thread safety possible without compromising performance.

26:28 I think that was a big part of what kind of went wrong earlier, three, four years ago in the first attempts where the degradation to standard library performance was so great.

26:38 a lot of folks were like, I don't know if this is going to work.

26:42 But to the great merit of the CPython core devs, they've put a ton of work into not only handling the reference counting issue,

26:52 but handling all the containers and standard library pieces that we depend on to make them

26:58 thread safe and performant under multiple threads.

27:01 Yeah, we've got the free threaded guide, right?

27:05 From the free threading guide, you're making me a little conscious about...

27:08 All the different ways that people say this.

27:10 The different ways to say it, exactly.

27:12 So I believe I've talked a little bit about this before on the show.

27:16 This is from the QuantSite folks who do a ton of great stuff in mostly the

27:21 data science side, but all over.

27:22 So they put up this guide about the status, installing it, et cetera, et cetera.

27:26 But maybe the most important thing is the tracker, right? That shows you which

27:31 Which packages support it?

27:33 I don't know.

27:33 There was another one that I had somewhere that actually had a...

27:36 There's a link I have in my slide to another stair disc.

27:38 Yeah, I got it from your slide.

27:39 That's right.

27:39 Yeah, that's it.

27:40 This is from Hugo.

27:42 So it's free-threaded wheels.

27:44 And honestly, this looks pretty good.

27:47 218 out of 360 top packages support it.

27:52 Yeah.

27:52 And this is, of course, the pattern that was set for migrating to Python 3,

27:57 the last sort of big, heavy migration we had to go through.

28:01 And it's an effective way to help communicate.

28:03 But this number is very good.

28:05 I mean, 218 out of 360 critical packages supporting free threading already.

28:11 It's really a minority interest at this time is, I think, really great.

28:15 I totally agree.

28:16 And I definitely get the feel that there's a lot of data science here.

28:21 I feel like the data science folks have an extra motivation to make this work

28:25 because data science folks, way more than web and sort of DevOps-y and whatever other people are

28:31 doing, there's not as much computational need in the same way, you know, but if you got a billion

28:36 rows and you want to jam on them, all of a sudden you're like, why do I have 20 processors and I'm

28:40 using one?

28:41 Yeah.

28:41 I mean, your escape hatch has been try to run it on a GPU or try to do multi-processing or try to implement it in C,

28:49 but implementing your own homegrown multi-threaded code in C or C++ isn't great.

28:55 You can use Rust.

28:56 Rust's multi-threaded support is fantastic.

28:58 And of course, we've seen a ton of Python C extension or rather extensions written in Rust,

29:03 where the threading story is excellent.

29:07 And we can get performance there.

29:09 But to have it in the language, there are places where we have to deal with heavy Python objects and being able to do

29:16 big stuff with them concurrently with lightweight threads is just a huge change.

29:20 It is a huge change.

29:21 I'm a little nervous about all of this stuff. I don't know. Not because I used to do a lot of C++ and a lot of C# and scientific computing and visualization type stuff.

29:31 And in the early days of my work, we did all kinds of threading and so on to get advantage of all the computation we can do, you know,

29:39 in those worlds, you think about pointers, shared data, allocations, race conditions,

29:46 deadlocks, like they're just always something that's kind of like, well,

29:49 as I'm thinking through architecture or how this works or if it's correct check check you like they're going through your

29:54 mind i don't think that's happened traditionally in the python space and i talk to people i don't

29:58 hear them going oh and we're using the re-entered lock here because of this and then we have a

30:03 semaphore so that we don't overwhelm like that just isn't there and so builds and ci passes for

30:09 free threading and actually is free of threading bugs or race conditions or deadlocks those are two

30:15 different things and so yeah yeah that's i don't know how you feel about that what do you think

30:19 use immutable data structures and don't try to mutate things in place while you're doing your

30:24 multi-threading and you solve a huge number you just avoid a ton of the problems and i think that's

30:30 that's i think that's true if you can if you can avoid doing in-place mutation while doing your

30:37 multi-threading it just removes a ton of the challenges that all of those different types of

30:42 locks that you mentioned are there to handle i think it's pretty rare that you really need to

30:48 get into that.

30:49 But again, what's fascinating is that Python has had all of the resources necessary

30:54 to handle locking as needed for multi-threaded code for a decade, probably.

31:01 It already has, all the tools are there. So if you do get in a complicated situation,

31:05 the tools are already there in the standard library.

31:08 But I think the other thing you bring up that is quite relevant is the testing regime of making sure that our CI is actually getting at the multi-threaded

31:19 scenarios that we need to exercise.

31:21 And that's something that I think you're right. A lot of Python projects haven't had that in their sort of CI battery of testing.

31:31 Yeah.

31:31 I think that agents, the AI agents actually could help a lot. I want a barrage of stress tests

31:38 for this thing using parallelism.

31:40 And we all have many, many core machines these days, right?

31:43 So you could do it.

31:44 You could do it.

31:45 Yeah, absolutely.

31:46 Absolutely.

31:47 I just, so I wanted to adopt this.

31:49 I'm like, oh, let me try for one of my websites because that would be really cool,

31:53 right?

31:53 Is if I could somehow just say, we're going to turn on multi-threading and server as eight cores.

31:59 So we're just going to have eight threads.

32:00 I mean, that gives me like eight X amount of processing on the CPU side without,

32:05 you know, farming that out to other workers and raising the RAM. Like this is a big part of my talk,

32:10 actually, at 5A.

32:11 But the free threading would make a huge bonus, a huge benefit to that, I think.

32:16 But then while we were talking, I just ran a little WC-L and I have 270 plus packages

32:25 in my virtual environment.

32:27 Now, some of those are like porting stuff for just the developer mode.

32:32 So let's call it 150.

32:34 What's the chances all 150 are green on this list?

32:37 I will bet you strongly that it's zero.

32:40 They don't all have to be, right?

32:41 Like the thing that does markdown parsing is probably only parsing a single.

32:46 You know, like it doesn't necessarily mean that I have to have all 150 checked off,

32:51 but it's got a little bit of a two to three feel, fortunately.

32:54 Like if you've got one thing that doesn't cross over, are you able to still make that move?

33:00 I mean, you could do the lock again.

33:01 Like, OK, we're just going to force single thread it onto this part of my code if it's really, really important.

33:06 But what do you think?

33:07 Well, so what you're pointing out is the challenge of thread safety when we have to resort to a lock.

33:13 But the other thing that we need to keep in mind, and this is sort of the peculiar situation we're in at this time,

33:19 is that if you first of all, if you have a package that is native Python,

33:24 there's no concern.

33:25 native Python packages will load in free-threaded Python, though they may not be thread safe.

33:30 But they will load and the gil will remain disabled.

33:34 The real issue that people have to be aware of, and I think the issue that's a challenge for adoption,

33:39 is that if you load a package that is a binary, that has not opted into free-threaded Python,

33:47 like PsychoPG as I show, The most popular Postgres database adapter for Python

33:53 for the most popular database.

33:56 yeah so if you load any wheel that is not compiled for three-threaded python it will

34:02 re-enable the GIL and that's a particularly troubling thing so to say it as i say in my slides

34:09 the GIL is a zombie right now in the free-threaded binary of python the GIL is not removed it is

34:17 disabled and we can turn it back on at the start of the python free-threaded python we can it can

34:22 also get enabled because you import a wheel.

34:26 So that's not compatible.

34:27 So what that means is any time in the life of your program, if you happen to have a process that or a function that has an

34:35 internal import, or you finally call on some routine, it's going to re-enable the GIL dynamically

34:40 in a moment.

34:41 And so if you had been counting on free threaded performance and the GIL then gets

34:47 enabled, your free threaded performance is going to go away and potentially your performance is

34:52 going to get much worse so i think that's the real check independent of getting uh you know thread

34:57 safety that's another challenge but just having the basic compatibility in the wheels is critical

35:03 to ensuring that your process remains without the gale for its full run yeah and i'm looking for

35:10 where the common is in your slides but somewhere you actually show the message so if you import

35:15 psycho pg which one was it psycho pg2 or whatever it was yeah i think it's then yeah then you get a

35:22 a warning, not an error, just a warning.

35:24 Well, we're not ready for a free threaded Python. So we've turned it off for the process for everything.

35:29 You're like, wait, what?

35:31 You can just turn it off.

35:33 No, no, no, no. Don't just turn it off. Like that's super subtle, right?

35:38 Yeah.

35:38 Yeah.

35:39 And so like people opting into people who were using free threading are probably using it for the performance and it's the stakes are high because

35:46 if the same free threaded code on standard python will in many cases go slower and sometimes a lot

35:54 slower whereas with free threaded python it can go half the speed or an order of magnitude faster

36:01 that's night and day and so you are so right now writing libraries or writing routines processes

36:07 to depend on free threaded python is great but you have to be super careful that uh you don't

36:13 incidentally import something that re-enables the GIL and you wonder why now things are taking you

36:19 know 10 times as fast as a lot and it's using not one core but all the cores and more memory you're

36:25 like wait it's using it more my compute or my server or whatever and it's slower this is going

36:32 slower i'm here for yeah yeah yeah that's right that's right i found it so your slide the title

36:36 raising the dead yeah yeah so you can actually ask the system is the GIL enabled right yeah so it's

36:42 So it's a private method, I guess, because it's still experimental.

36:46 It's a leading underscore is gil enabled, but that is your runtime check to see if the

36:51 gil is enabled.

36:52 Now, I think what I'm not quite certain about, so it does give a warning, but I think what

36:57 it says is that if you start free threaded Python with the flag of the gil always disabled,

37:05 it might err instead of giving you a warning.

37:07 I haven't experimented with that yet.

37:09 So there might be a way to lock it down and say, if anything tries to re-enable the gil,

37:14 fail, which is kind of the default I would prefer.

37:17 Yes.

37:17 But actually, I think it's YOLO.

37:20 Let me read the message.

37:22 So here's the code.

37:23 Run free-threaded Python.

37:25 Import this.

37:25 Is gil-enabled?

37:26 No.

37:27 Import Psycho PG2.

37:28 Big message I'm about to read.

37:30 Is gil-enabled?

37:31 Yes.

37:31 Right?

37:31 So it's turned it back on, which is just the fact that that can happen at all is very weird

37:36 to me.

37:37 Yeah.

37:37 But OK, here's the message.

37:38 491.

37:39 runtime warning, not error, the global interpreter lock gil has been applied,

37:44 has been enabled to load the module psychoPG2.underscorePsychoPG, which has not declared that it can run safely

37:51 without the gil.

37:52 And here's why I think it's YOLO.

37:53 To override this behavior and keep the gil disabled at your own risk, run with Python underscore gil equals zero.

38:02 Yeah.

38:03 And the environment.

38:03 So because the at your own risk, rather than it's going to stop, it's going to be like Right,

38:07 right, you're right. Let's roll, baby.

38:08 Let's roll.

38:09 Yeah, so that will ignore compatibility, but it's not making any claim for thread safety.

38:15 I think that's what's doing.

38:16 At least the gil won't be dynamically re-enabled, but what they're saying is you have no idea what's going to happen with this package.

38:23 Yeah, we've explicitly said that this is probably going to have a threading bug.

38:28 So, you know.

38:31 Yeah.

38:32 Then again, these libraries are complicated.

38:35 There's often so much of them, and I think this kind of drives me crazy.

38:38 We're not as bad as the JavaScript people.

38:40 Let's just feel a little better about yourself.

38:42 Look in that direction.

38:43 However, why do I have 270 packages in my web app?

38:48 Like that is ridiculous.

38:49 I'll bet you there's a bunch of them that I'm using some package and it said,

38:53 oh, I need like some random small little piece that this other much more complicated library offers.

39:01 I'm going to add that random, that library so I can have that random small piece.

39:04 I think there should be a lot more vendoring in or just, hey, Claude, I need to resolve a DNS.

39:11 Can you just write me the code to give me the, given a DNS name, give me the IP address

39:17 instead of depending on a DNS library that depends on four other things?

39:21 You know what I mean?

39:21 That's probably 20 lines of code that I don't have to write.

39:24 And we could have this dependency story down to 20 or something instead of 200.

39:29 Yeah.

39:30 And that makes it much easier.

39:31 I don't know.

39:32 I don't know how to solve this problem, but that's the place we're in.

39:34 Yeah, I definitely feel that pull as well in my own work where, you know, I can look for a small library to do something or I can have my agent just write it and have it be,

39:46 you know, 95% or 100% of what I need.

39:50 So we don't get as much reuse through that mechanism, but it does avoid a lot of dependency problems.

39:57 Yeah, it avoids this threading issue if the third level transit of dependency is not thread ready yet.

40:03 You could tell your agent, make these 20 lines of code thread safe, but it's really hard to tell it to make like all of these dependencies you don't control behave in a way, you know?

40:12 Yeah, that's right.

40:13 The other one that is honestly a 2026 top hit as well.

40:17 Not as much as AI, but supply chain attacks and vulnerabilities.

40:21 And you know what you don't get if you have a static file that has got 20 lines of Python you wrote in?

40:26 Supply chain exposure.

40:27 Not on that file anyway.

40:28 You know what I mean?

40:30 Yeah, that's true too.

40:31 I mean, that's absolutely the case.

40:33 there is a benefit from reducing your dependency exposure for not only supporting new features like this,

40:41 but also for security.

40:42 Absolutely.

40:43 You work, at least for a while, in a very high stakes industry.

40:47 What have you all been doing with dependencies and supply chain concerns?

40:50 Like, has this been something that's concerned you as well?

40:54 Yeah, absolutely.

40:56 Keeps you up in light, right?

40:58 You're like, oh God.

40:58 Oh, yeah.

41:00 So when I took the role of CTO, I started getting really involved in cybersecurity.

41:07 And when I looked at the security platform my organization had, I was quite impressed.

41:12 We had so many things covered.

41:14 But one aspect that was clearly not as secure as it could be was how we were managing Python dependencies,

41:23 which we were using Python heavily.

41:25 And we essentially let people download and install and try whatever they want,

41:31 which for a small org is very practical.

41:34 And developers like that freedom, but there's tremendous risks with that approach.

41:42 Big organizations will turn to things like JFrog Artifactory or AWS.

41:47 I forget their tool of the same name.

41:51 It was, of course, the JFrog artifactory that the rogue OpenAI agents hacked

41:57 to enable them to communicate and escape their sandbox.

42:03 Yeah, that was a hugging face incident that they basically hacked artifactory,

42:07 but not to do anything nefarious, but to use it as a command and control

42:12 and conversational back channel so they could get out.

42:15 It was so weird.

42:16 Yeah, absolutely.

42:17 So and then the thing that bothers me, though, is, you know, people, unless you have unless users in your organizations have completely locked down systems,

42:25 even if you set up an alternate pip or an artifactory on your in your network,

42:31 if someone takes their laptop to another network, they can just go to pip or they can just download the package through another side channel and bring it in.

42:38 So what I found was that in my view, there seemed to be no really foolproof way to control what packages end up on your system without going to an extremely draconian level of controls on user level systems.

42:53 And that level of control wasn't where my org was ready to go.

42:57 So that was a big part of why I created this tool called Fetter, which is a Rust-implemented local scanner that can find all of the Pythons, all of the Pythons on your system,

43:09 all of the site packages directories in every single place, and give you a list of all of the packages that have CVEs and rank them and do a bunch of fun stuff with that.

43:20 So that was kind of my exploration of how to solve that problem.

43:24 It's slow.

43:25 Someone may have downloaded a package and Fedder is not going to notice until it does a scan.

43:30 But when I see a report about a Python package that has been compromised or whatever,

43:36 I can do one little search and find out if anyone in my organization has that package.

43:41 And that's at least better than not knowing.

43:44 Yeah, it definitely is.

43:45 I don't know.

43:45 It's a very challenging problem because some of the magic of these modern programming languages

43:50 is some incredible feature is just install or uv pip install away, right?

43:55 I mean, we've got the import anti-gravity, right?

43:59 Yeah.

44:00 That's literally was basically what it was about was the XKCD.

44:04 And by the way, if you don't know this, type import anti-gravity into your ripple.

44:07 But, you know, it's like the old cartoon is like there's someone up there flying.

44:11 How are you flying?

44:12 Python.

44:13 I learned it last night.

44:15 Just import this.

44:16 I just typed import anti-gravity.

44:18 Off it goes, right?

44:19 Yeah.

44:20 so gotta be careful bashing on it too hard right but at the same time it can get too i don't know

44:26 it can be it can be a bit too much yeah we'll get back to free 30 but i just one more thought is i

44:30 have you know i in the week most weeks with some extra ai credits not this week is today my credits

44:37 reset and i've got three three percent left that i'm saving if i need them for something like but

44:43 in general i've got a you know i've got 30 40 percent of whatever i didn't use just hanging

44:47 around.

44:48 I've considered just going into like, okay, what packages do I use?

44:52 Let me just do a deep analysis of the threading, write a bunch of tests and find any bugs and kind of just try

44:59 to work my way one at a time through my dependencies until I can be all green on that.

45:03 Are we free threaded yet?

45:05 Checkbox.

45:06 Maybe I'll do that at some point. That'd be fun.

45:07 Well, I think the, if the performance you're looking for is overwhelmingly in your web server,

45:13 I think that's the first place you need to look and see if the web server you're using,

45:19 what its thread story is.

45:21 And I would start off by kind of just building some isolated tests with that and see if you really get better performance.

45:30 I think that's a key question.

45:32 It is a key question.

45:33 I think it would.

45:35 I definitely think it would.

45:36 Right now I have it turned off because I don't think it's worth it.

45:38 However, because all the operations are async, so it's kind of in a sense thread.

45:43 But if I could, if I could turn on true threads, I certainly would.

45:46 I certainly would.

45:47 I mean, we were all excited when our web servers, our Python web servers got async.

45:51 We were like, this is fantastic.

45:52 And then that was like a whole project.

45:54 But all the while, yes, async can do a lot.

45:56 But if you have performant lightweight threads, they can do more.

46:01 Yeah, absolutely.

46:03 Let's see if I can find your slides again.

46:07 Here we go.

46:08 I don't know where I put it.

46:08 Oh, here they are.

46:09 Maybe you could talk us through some of the trade-offs.

46:12 Like what you found, because you've got a bunch of graphs and sometimes this was better and sometimes it wasn't.

46:17 So maybe we can talk a bit about that.

46:18 What do you think?

46:19 Sure.

46:19 Yeah.

46:20 So the.

46:21 And then I want to talk about your thread pool magic.

46:24 Sure.

46:24 Yes.

46:25 So.

46:26 Keep loading.

46:27 Yeah.

46:27 So the.

46:28 In my work in data frame libraries, I was constantly frustrated by people showing performance tests on an arbitrary frame.

46:36 And it's like, OK, so you made it go faster here.

46:39 But what I found through systematic performance analysis is the shape of the frame.

46:45 Is it wide?

46:45 Is it tall?

46:46 Is it square?

46:47 Makes a big difference.

46:48 And for some operations, the types, are they floats?

46:50 Are they integers?

46:51 Are they strings?

46:52 Will make a huge difference as well.

46:54 So that led me to adopt this kind of pattern.

46:57 Whenever I'm doing performance tests on tabular data, I systematically vary the tables into

47:05 tall, square, and wide groups.

47:09 And depending on the types of operations you're doing, this can show a great diversity of performance.

47:14 Now, for this study, I was doing one type of operation, which is row-wise function application.

47:20 In a lot of financial data modeling, this is a common paradigm where you have a bunch of data in a table,

47:29 and maybe those columns are characteristics, and you go and you want to apply a function to every row in that table

47:35 to do something with those characteristics and derive a new column or a new data set or what

47:40 have you. So row-wise computation is something that comes up all the time.

47:45 And so the first thing I looked at here was if I have a simple giant table of a NumPy two-dimensional array

47:54 of integers, and I'm just calling sum on each row, can I go faster by doing those row sums with

48:02 multiple threads.

48:03 And this here, if the table is tall... Are you talking summing multiple columns,

48:08 like summing purchase and discount or something like that? Just summing a row.

48:12 Just summing each row. A single row, okay.

48:13 A single row, yeah.

48:14 And so if the table is tall, those rows are relatively short and there's many more rows. If the table is wide,

48:22 each of those rows is more work and there's fewer of those rows.

48:26 So my first tests of working with some on a two-dimensional NumPy array of,

48:33 I think that's 100 million elements total, shows that with the gill, every application of threads

48:39 is worse.

48:41 And that's expected.

48:42 That's what we're used to in Python, even though this is NumPy.

48:46 With the no gill, I was able to show that for tall and square tables, performance degraded.

48:54 But actually able to get a reduction almost to maybe two thirds the performance just by using,

49:03 I think that was eight threads on summing the rows of an umpire array. And that was like one of the

49:08 first insights where I was like, I can't believe this is possible.

49:11 Even though the other cases don't work out well, having that one work was just a really positive sign.

49:16 Yeah, that's awesome.

49:17 So there are certain situations, and this is kind of what I was hinting at before,

49:20 like if you don't give it enough work, it just doesn't pay off.

49:23 But your next example for even square sums or something along those lines, basically doing more work per row than any form of wideness,

49:34 square or wider, it would start to be really effective, right?

49:37 Yeah, that's right.

49:39 And this came out of, so in implementing concurrency for static frame, I put the opportunity to use multiprocessing and multithreading because even five or 10 years ago,

49:49 I started to see that there were cases where multi-threading standard NumPy would give you

49:56 better performance.

49:58 But those cases were hard to find and they really had to be tuned.

50:03 And that really depended on how much work was happening purely in NumPy C code,

50:08 where it often releases the GIL versus how much work was happening at the Python layer.

50:13 So with this next set of examples, we have operations that are using intermediate NumPy arrays.

50:19 So we're finding all the even numbers.

50:21 That gives us back a Boolean array.

50:23 And then we're using that Boolean array to select a subset from another array.

50:27 So while the bulk of the work is in NumPy, we have intermediary Python objects that are coming back.

50:32 And that additional overhead is enough to really tip the scales where when we remove the gill,

50:39 a square two-dimensional array or a wide two-dimensional array can deliver truly an order of magnitude better performance,

50:47 which is my gold standard.

50:49 If I can go an order of magnitude faster, I have every reason to be happy.

50:54 Yeah, absolutely, absolutely.

50:56 So I want to close this out by talking about your thread pool story.

51:02 So we've got a thread pool and we've got a multiprocessing pool in Python since way back when.

51:08 The thread pool is of marginal use.

51:11 If you're doing certain things where those operations are releasing the gill, then the thread pool can be really valuable.

51:17 But if it's all just pure Python and you're not releasing the gill, it's still just kind of serial anyway.

51:23 The multiprocessor one, on the other hand, does a lot more.

51:26 But you built a cool library that kind of takes some of the best practices around threading and works them into Python based on whether or not the GIL is enabled or not and things like that, right?

51:36 Yeah.

51:37 So the concurrent futures library in Python is just gorgeous.

51:41 I mean, it's been it's one of the one of my favorite Python pieces, and it gives you a singular interface to do multithreading and multiprocessing.

51:49 And that made it so easy for me to switch back and forth for the over the last decade and kind of see where our threads working yet, our threads working yet.

51:59 And I think they've also added the same interface for sub interpreters, which we haven't talked about today.

52:05 But sub interpreters was the other escape hatch for concurrency in Python.

52:08 And I think they've made the concurrent futures pool interface available for sub interpreters, which is super cool.

52:16 But as we talked about before, right now and for I'm not sure how many years into the future,

52:23 if you want to use free threading, you take a risk that someone's going to use your code and not be running free threaded Python.

52:30 either because you're distributing a library and someone might not have free threaded python

52:35 or someone's environment they've imported a wheel that's not compatible and the GIL gets re-enabled

52:41 so my thinking was if i want to start building code that really is counting on free threaded

52:47 availability i i i need a tool that will identify if the GIL is enabled and if the GIL is enabled

52:55 stop doing concurrency.

52:58 So that's what this conditional futures package is.

53:01 And I was really pleased with this title because I love the idea.

53:05 Conditional futures.

53:06 You may get a thread pool with threads or you may get something that looks like a thread pool with threads

53:12 but is actually just conventional serial processing.

53:16 And what makes the determination is if the gil is enabled.

53:20 So we dynamically check before every call.

53:23 It's a context manager, just like normal thread pool creation.

53:27 It has the same thread pool interface.

53:29 It's a subclass.

53:30 It's type compatible.

53:31 And what it will do is it will use threads if the gil is disabled.

53:37 The gil is not disabled.

53:38 It will just use the same code, but only use a single threaded operation in the parent thread.

53:46 It won't even spawn a new thread, really giving you the best of both worlds.

53:49 This is great because it lets you write code, if I get to the right one, it lets you write code as if it was multi-threaded.

53:57 And then it kind of degrades to, well, we can really only have one thread.

54:01 So the worker count falls back to one, right?

54:04 But you don't have to do any conditional, like does the conditionals, even though it's called conditional thread pool executor.

54:09 You don't have to mess with it.

54:11 You just treat it like you have free-threaded Python fully and it will manage it, right?

54:17 Yeah, exactly.

54:17 And it will fall back to just executing in the parent thread.

54:20 And again, the reason we need this right now, if you're trying to rely on free threaded Python,

54:25 is that if you happen, if your code happens to run with the gil enabled,

54:30 your performance will degrade materially, like very bad.

54:34 So it's like to avoid that, we can just fall back into running everything in the parent thread,

54:39 not creating any new threads.

54:41 But this gives us one Python interface to do that.

54:43 And to be clear, when you say it degrades, It doesn't mean if I could have got a 5x speed up with threading,

54:48 it only gives you one.

54:51 It's actually slower than single threaded work.

54:54 Like it adds all this overhead of the threads and the context and the memories,

54:57 but it doesn't have any more compute to hand to it.

54:59 So it just slows down slower than if you did never do any threading, right?

55:03 Yeah, absolutely.

55:04 It can be really bad.

55:05 It can be very bad.

55:06 And so my big takeaway from your talk was I knew about a lot of the GIL stuff and I knew

55:14 about a lot of the patterns and trade-offs of threading.

55:17 I didn't know that GIL could be re-enabled in free-threaded Python.

55:21 That caught me off guard.

55:22 Yeah, yeah.

55:23 And that's, I think, it's a curious choice, but I think it's the strange period we're in right now.

55:30 And so it is, I think, the number one thing for people to watch out, again,

55:33 if they're starting to try to depend on free-threaded Python, and especially if they want to distribute libraries

55:40 that depend on free-threaded Python, because you just don't know which version of Python your users are going to use

55:47 or if they're going to implement a wheel that re-enables the guild.

55:50 I think that's also, you know, I kind of lamented that a lot of folks in the Python space

55:55 aren't thinking about parallelism, deadlocks, race conditions, et cetera.

55:58 I think a lot of where the free threading Python stuff is going to show up is in libraries and stuff.

56:04 And people may not even directly interact with it.

56:07 Yep.

56:08 Right.

56:08 But they're like, well, I got this other library and it's really fast because it's free threaded.

56:11 All I did is call the one, you know, non-async function and it just ran.

56:16 But internally, it did something like your conditional thread pool or something.

56:20 Yeah, and that's why I'm so excited about this because in Python, the opportunities for using concurrency were very few.

56:28 They were big, heavy processes that use multiprocessing that you would never really,

56:33 that wouldn't work with threading.

56:35 And you wouldn't really put into a library because a library can't make assumptions about number of cores or amount of work to really tune the concurrency to be sure that you would get a benefit.

56:46 But for the first time in Python, we now have lightweight true thread concurrency.

56:52 That means that there's this whole range of small to middle sized work units that can now take advantage of concurrency and deliver material results.

57:01 Lots of little bits of concurrency that we just didn't have access to before.

57:05 And so, yeah, I think you're exactly right.

57:07 Library authors and maintainers can start to integrate multi-threaded routines into standard operations and have good confidence that their users on whatever system they're running are going to get good results.

57:21 For sure.

57:22 Also mentioned talking to your agents.

57:24 We talked about making them more friendly, but specifically with regard to concurrency.

57:30 Yeah.

57:30 So this is one of my favorite points is that agents generally in Python,

57:37 I found them to be serial first.

57:39 But even in Rust, a language that has excellent multi-threaded support and libraries,

57:45 I find the agents to be serial first.

57:49 an example in python is a situation where you're downloading a bunch of files in a loop this is the

57:57 classic example of where python threading has always been effective and you may not want to

58:02 write that little additional code to make it free threaded but if you just select that code and say

58:06 hey make this free threaded your agent will do it and but it takes looking at the code realizing it's

58:12 serial, and then asking.

58:14 And then on the Rust side, you know, libraries like Rayon provide really awesome high level tools to, for example,

58:22 if you have a loop that's computing, doing a bunch of work on each iteration of that loop,

58:28 Rayon gives you very nice high level utilities to make those work units multi-threaded.

58:35 And again, I find that the agents don't reach for that first, you really need to prod them and say,

58:41 hey, use Rayon to make this loop multi-threaded and it'll do it and it'll be great.

58:46 That's awesome.

58:47 Most of the time, most of the time.

58:49 That's fair, that's fair.

58:51 Most of the time this threading will be great.

58:52 Except for when your program just doesn't respond and it has zero CPU usage and you're just like, why?

58:59 What is happening there?

59:01 Bingo.

59:02 Yeah, yeah, yeah.

59:03 All right, Chris.

59:04 Well, that's probably what we got time to cover.

59:07 give people some advice on adopting free-threaded Python, what we got to look forward to in the next couple of years.

59:13 Great.

59:13 Thanks. Yeah, I'm eager to see this evolve in the Python community.

59:19 You know, as I said in my talk, there's a lot of effort has been put towards making Python faster over the last three to five years.

59:26 And a lot of those that work, we've seen the benefits.

59:31 But I feel this one is a real game changer for certain kinds of work that really will be a much more material benefit for a lot of folks.

59:40 I agree.

59:41 We can make our libraries 30% faster, and that's a lot to celebrate.

59:45 But if we can make it run actually on 20 cores, that's more than 30%.

59:50 Exactly.

59:51 That's right.

59:52 All right.

59:52 Thanks for being here.

59:53 It's been really fun to dive into this free threading thing, and your talk was really great.

59:57 So I'll link to it.

59:58 People can check it out when it comes out.

01:00:00 Great.

01:00:00 Thanks.

01:00:00 Happy to be here.

01:00:01 See you later.

01:00:02 All right.

01:00:02 Thank you.

01:00:03 This has been another episode of Talk Python To Me.

01:00:06 Thank you to our sponsors.

01:00:07 Be sure to check out what they're offering.

01:00:08 It really helps support the show.

01:00:10 It's Black Friday week here at Talk Python.

01:00:13 The entire library is $50 off with the Everything Bundle.

01:00:17 And there's a new starter set of courses, four courses, for learning Python in the age of AI.

01:00:24 And that's only $56.

01:00:26 The Talk Python in production book is 25% off and membership at Talk Python is 30% off,

01:00:32 which gets you into our discords and monthly meetups.

01:00:35 Visit talkpython.fm/Black Friday.

01:00:38 The sales end December 2nd.

01:00:40 Thanks for supporting the show.

01:00:42 If you or your team needs to learn Python, we have over 270 hours of beginner and advanced courses on topics ranging from

01:00:49 complete beginners to async code, Flask, Django, HTML, and even LLMs.

01:00:54 Best of all, there's no subscription in sight.

01:00:57 Browse the catalog at talkpython.fm.

01:01:00 And if you're not already subscribed to the show on your favorite podcast player,

01:01:04 what are you waiting for?

01:01:05 Just search for Python in your podcast player.

01:01:07 We should be right at the top.

01:01:08 If you enjoyed that geeky rap song, you can download the full track.

01:01:11 The link is actually in your podcast blur show notes.

01:01:14 This is your host, Michael Kennedy.

01:01:16 Thank you so much for listening.

01:01:17 I really appreciate it.

01:01:18 I'll see you next time.

01:01:31 I'm out.

Talk Python's Mastodon Michael Kennedy's Mastodon