返回资讯中心
外部精选
软件工程
#社区热议

How Fast is Python 3.15?

It's October once again, and that means it is time to take the new release of Python for a spin (technically, it is the 3.15.0rc3 release that I'm using, the official 3.15 release is still a few days out). As I did with…

Hacker NewsQem2026/10/6 · 25 天前10 分钟阅读

以下正文同步自 Hacker News,版权归原站所有,已转换为易读排版。

miguelgrinberg.com

Home

My Courses and Books

Consulting

About Me

Light Mode

Dark Mode

System Default

-->

How fast is Python 3.15?

Posted by

on 2026-10-05T10:13:17Z under

It's October once again, and that means it is time to take the new release of Python for a spin (technically, it is the 3.15.0rc3 release that I'm using, the official 3.15 release is still a few days out). As I did with my Python 3.14 performance article of a year ago, today I'm sharing a new run of my informal Python benchmark, comparing Python 3.15 against previous interpreters all the way back to 3.10.

If you are not interested in the charts and the tables and just want to read my analysis, feel free to jump to the conclusions section at the end.

I just called my benchmark "informal". What does that mean?

Getting an objective and universal measure of the performance of a programming language is impossible. All you can do is write some programs and run them to get a measure of their performance. Other programs may show similar performance characteristics or they may not, there is really no way to know. My intention with this benchmark is just to get a feel for the performance changes across versions of Python, but I want to make it clear that I'm not trying to obtain a comprehensive performance profile of the Python interpreter.

For my benchmark I will be running two programs called fibo.py and bubble.py, which you can inspect if you like. These are the same programs I used in past editions of this benchmark. The first calculates numbers from the Fibonacci sequence, and the second sorts numbers using the bubble sort algorithm.

I've chosen these two programs as representative of two classes of algorithms. The Fibonacci calculation is done using recursion, which I have found to be somewhat inefficient in Python interpreters. On the other side, the bubble sort only uses for-loops, without any recursion. There are other types of programs that my benchmark does not attempt to cover. In particular, note that I'm not including I/O bound code in this benchmark.

Because some of the performance improvements in recent Python versions revolve around multi-threading, I also created a multi-threaded variation for each program, so in total I have four different tests.

The complete testing matrix is actually fairly complex, because I have to run the four program variations under all the Python versions, plus the JIT and free-threading alternatives for those that have them. I like to run the tests under PyPy as well, because this interpreter has shown impressive performance in past runs of this benchmark. And to place Python performance within the wider ecosystem, I've also ported the two programs to JavaScript (Node.js) and Rust.

Here is the full test matrix that I've worked with:

Readers of my previous benchmarks may recall that I had an additional dimension in my matrix for Linux vs. macOS. Given that there were no significant differences between them in the two previous runs of the benchmark, I've decided to drop the macOS tests this time around, so all tests were executed on my Linux laptop, which has an Intel Core i5 CPU and runs Gentoo Linux.

The method I'm using to measure the performance of each participant in this benchmark is to run the test program three times and take the average duration of the three. In the tables of results that I share below I also show the speed difference versus the 3.15 version, and when it makes sense also the speed difference versus the previous version of a given interpreter. For speed comparisons I'm using a simple ratio, where 1x means same speed, 0.5x means half speed (or that it took twice the time to run), 2x means twice as fast (or that it ran in half the time if you prefer), etc. Hopefully this makes sense.

Let's get started. The first test calculates the first 40 Fibonacci numbers.

正文由 探How 从来源站点 RSS 同步,内容未经改写;遇到排版缺失或需要图片、视频时请以原文为准。

打开原文
去社区讨论 →