PROGRAMMING LANGUAGES · EPISODE 9 OF 15 · 11 MIN ·

Why is a 'slow' language the one everyone uses for AI?

Python has a reputation. It's easy to read, easy to learn, and slow. Yet, by GitHub's 2025 count, it's the main language for new AI projects, and AI is some of the most demanding computing there is. So how can a slow language run some of the most demanding software there is? And is it really slow at all?

▶ Watch on YouTubePlay the whole Programming Languages series ▶

The full story

The episode's narration, word for word. Numbers link to the sources below; timestamps play that moment.

The question 0:00

Python has a reputation. It's easy to read, easy to learn, and slow1. Yet, by GitHub's 2025 count, it's the main language for new AI projects 2, and AI is some of the most demanding computing there is. So how can a slow language run some of the most demanding software there is? And is it really slow at all?

A Christmas project 0:26

Python began as a holiday project 3. Guido van Rossum, a Dutch programmer, worked at CWI, a research institute in Amsterdam 3,4,5. His group needed a better way to look after their computers than writing programs in C or shell scripts 3. So during the Christmas holidays of 1989, with time on his hands, he started writing a language of his own 3.

Posted to the world 0:52

After just over a year of work, he posted version 0.9.0 to USENET, a worldwide network of online discussion groups, in February 1991 3,6. The name has nothing to do with snakes 3. He was reading scripts from Monty Python's Flying Circus, the BBC comedy, and wanted a name that was short, unique and slightly mysterious 3.

Readable on purpose 1:21

Here's a little Python, run for this episode 7. A list of towns, and for each town, if it starts with G, print a message. Notice there are no curly brackets marking where the loop begins and ends: the indentation is the structure 8. That idea came from ABC, an earlier language Van Rossum had worked on at CWI 3. Python's design notes say it means the computer and the human reader can't disagree about what belongs where 8.

Readability counts 1:51

Python's official style guide puts it plainly: one of Van Rossum's key insights is that code is read much more often than it's written 9. There's even a poem about it, built into the language 10. Type "import this", and Python prints the Zen of Python, nineteen sayings by the longtime Python programmer Tim Peters 10,7. Simple is better than complex, it says, and seventh on the list, readability counts 10,7.

So how slow? 2:21

So what's the catch? Let's time it, on the computer that made this video 7. Here's one job written two ways: add up the squares of the first million whole numbers 7. On the left, a plain Python loop. On the right, one line using NumPy, a library we'll come to 11. Both print exactly the same answer 7. But the NumPy version ran more than fifty times faster 7.

Every number is an object 2:49

Why? Start with what a number is in Python. It isn't just a number 12. It's a whole object, carrying a running count of who's using it and a note saying what kind of thing it is 13. Ask Python how big the number forty-two is, and it says twenty-eight bytes 14,7. Store it NumPy's way and it takes eight, which is just the number 11,7.

Questions at every step 3:14

And a Python list doesn't hold numbers side by side. It holds addresses, each pointing to one of those objects 8,1. Then, because Python only finds out what things are as it runs, every pass through the loop has to check 1. What kind of thing is x? Still a whole number? Then it can use the whole-number multiply, and build a brand-new object to hold the answer 1,15. As we saw in episode two, the interpreter also decodes each instruction every time around 16,17. A million passes means a million rounds of questions.

Numbers in a row 3:53

Scientists hit this problem early. In the mid-1990s, a package called Numeric gave Python arrays of numbers, and it was written in C 18. One of its first jobs was steering C++ programs for fusion research at Lawrence Livermore National Laboratory 18. A rival, Numarray, was built to handle huge images from the Hubble Space Telescope 18. In 2005, NumPy united the two, and it later helped produce the first image of a black hole 18.

Where the loop runs 4:27

Here's NumPy's trick. Every number in a NumPy array is the same type, packed side by side in one block of memory, like eggs in a carton 11,1. You write one Python instruction for the whole array, and the loop runs inside pre-compiled C code, with no Python in between 11. That's called vectorisation: no loop in your code, because it's happening behind the scenes 11. NumPy's own documents call it near-C speed with Python's simplicity 11.

The chef and the kitchen 5:00

Think of Python as a head chef calling orders to a kitchen. If the order is "dice ten thousand onions", a slow chef hardly matters: the kitchen does the work. If the chef calls out every single onion, the kitchen waits on the chef. That's the plain loop. Here's where the picture breaks. On an ordinary processor there's no separate kitchen: NumPy's compiled code runs on the same chip 11. It skips the questions, works on numbers packed side by side, and for grid maths it calls a specially tuned maths library 1,11,18. And the kitchen only cooks dishes it already knows 18.

AI is a lot of multiplication 5:42

So what does AI actually spend its time on? A lot of it is multiplying big grids of numbers, which mathematicians call matrices 19. The graphics-chip maker NVIDIA calls matrix multiplication a fundamental building block of neural networks 19. Multiplying two grids of two hundred by two hundred takes sixteen million arithmetic operations 19,7. Written as plain Python loops, and as one NumPy line, the NumPy version here was more than a thousand times faster 7.

Why AI chose Python 6:16

Deep learning didn't start in Python 20. Early neural network tools were written in Lisp, Lua and C++ 20. But the team behind PyTorch, a deep learning library, wrote in 2019 that Python's large ecosystem had made it an essential skill for researchers 20. Since 2014, they said, most deep learning frameworks had settled on a Python interface 20. Other libraries, such as TensorFlow and JAX, run their arrays on ordinary processors and graphics chips too 18.

Python gives the orders 6:52

The same paper explains why Python's speed barely matters there 20. PyTorch's core, the part that does the maths, is written in C++ 20. The heavy maths runs on graphics chips, through NVIDIA's CUDA system for running general programs on them 20,21. Python just queues up the orders, and the graphics chip works through them 20. In one example they traced, the graphics chip's work took about three times longer than the processor took to queue it 20. So the chip stays busy, even with what the authors call a fairly high-overhead language in charge 20.

What Python costs 7:30

You can see that on an ordinary computer too. Here's the same one-line multiply, run on a tiny two-by-two grid, and on two grids of two thousand by two thousand 7. The tiny one is almost all overhead: the fixed cost of giving one order 7. The big one is sixteen billion operations 19,7. Python's share of the big job was less than a thousandth of the time 7.

Where the reputation is fair 7:56

So is the reputation wrong? Not entirely. Plain Python loops over lots of numbers really are slow, as we measured 7,1. Standard Python also has a lock, called the GIL, that lets only one thread run Python code at a time 16. And when no library already does what you need, the fast version has to be written in another language, or with tools that compile Python-like code, such as Numba and Cython 18.

Wanting both 8:25

That two-language cost is why some people build new languages. In 2012, the creators of Julia wrote that they wanted the speed of C with the flexibility of languages like Ruby, and something as usable as Python 22. It's one attempt to get both in one language. Python's answer has mainly been to lean on its libraries 18.

Python gets faster 8:49

Python itself is also speeding up. Version 3.11 was about twenty-five percent faster on average than the one before, by the Python team's own benchmarks 15. Version 3.14, released in October 2025, made an optional build without the GIL officially supported, so threads can run at the same time 23. The cost is roughly five to ten percent on code that uses a single thread 23.

Where it stands 9:17

In Stack Overflow's 2025 survey, 57.9 percent of developers who answered had done extensive work in Python in the past year 24. That's up seven points in a year, which the survey's writers linked to AI, data science and back-end work 24. Among people learning to code it was the top language 24. The TIOBE index, which counts search results, ranked it first in September 2026, though with a smaller share than a year before 25. And GitHub found Python in nearly half of all new AI projects in 2025 2. In the same report, as we saw in episode six, TypeScript overtook Python as the most used language on GitHub overall 2.

The slow part isn't the work 10:05

So is Python slow? Running its own loops, yes 7,1. But in AI, Python isn't doing the heavy lifting 20. It's the readable part that people write, while the maths runs in compiled code underneath 11,20. And much of that code, from NumPy's insides to PyTorch's core, is written in C and C++ 11,20. So why is so much still built on a fifty-year-old language?

Sources

Every factual claim in the episode is tied to one of these. Spotted an error? Tell us.

  1. Jake VanderPlas, "Why Python is Slow: Looking Under the Hood", Pythonic… — jakevdp.github.io
  2. GitHub Blog, "Octoverse: A new developer joins GitHub every second as AI leads… — github.blog
  3. Python Software Foundation, "General Python FAQ" (What is Python?; Why was Python… — docs.python.org
  4. Wikipedia, "Guido van Rossum" (accessed 7 October 2026) — en.wikipedia.org
  5. Centrum Wiskunde & Informatica, "About CWI" ("the national research institute for… — cwi.nl
  6. Guido van Rossum, "A Brief Timeline of Python", The History of Python blog, 20 January… — python-history.blogspot.com
  7. This episode's own check, calc.py (run 2026-10-07 on an Apple M1 Mac: CPython…
  8. Python Software Foundation, "Design and History FAQ" (indentation; how lists are… — docs.python.org
  9. Guido van Rossum, Barry Warsaw, Alyssa Coghlan, "PEP 8 – Style Guide for Python Code" — peps.python.org
  10. Tim Peters, "PEP 20 – The Zen of Python" — peps.python.org
  11. NumPy documentation, "What is NumPy?" — numpy.org
  12. Python Language Reference, "Data model: Objects, values and types" — docs.python.org
  13. Python/C API Reference, "Common Object Structures" (PyObject) — docs.python.org
  14. Python Standard Library, "sys" (sys.getsizeof) — docs.python.org
  15. Python Software Foundation, "What's New In Python 3.11" (Faster CPython) — docs.python.org
  16. Python Software Foundation, "Glossary" (bytecode, virtual machine, global interpreter… — docs.python.org
  17. V8 team, "Sparkplug: a non-optimizing JavaScript compiler", v8.dev, 27 May 2021… — v8.dev
  18. Charles R. Harris, K. Jarrod Millman, Stéfan J. van der Walt et al., "Array… — nature.com
  19. NVIDIA, "Matrix Multiplication Background User's Guide", Deep Learning Performance… — docs.nvidia.com
  20. Adam Paszke, Sam Gross, Francisco Massa et al., "PyTorch: An Imperative Style,… — arxiv.org
  21. NVIDIA, "CUDA Programming Guide", §1.1 Introduction ("In 2006, NVIDIA introduced the… — docs.nvidia.com
  22. Jeff Bezanson, Stefan Karpinski, Viral B. Shah, Alan Edelman, "Why We Created Julia",… — julialang.org
  23. Python Software Foundation, "What's New In Python 3.14" (released 7 October 2025;… — docs.python.org
  24. Stack Overflow Developer Survey 2025, Technology — survey.stackoverflow.co
  25. TIOBE Index, September 2026 (read 7 October 2026) — tiobe.com

Researched and scripted with AI assistance, fact-checked claim by claim, with synthetic narration and diagrams drawn in code. How we make episodes.

More from Programming Languages