🌐
Python documentation
docs.python.org β€Ί 3 β€Ί whatsnew β€Ί 3.12.html
What's New In Python 3.12 β€” Python 3.14.3 documentation
February 23, 2026 - The performance of writing to sockets in asyncio has been significantly improved. asyncio now avoids unnecessary copying when writing to sockets and uses sendmsg() if the platform supports it.
🌐
Medium
theanalyticsedge.medium.com β€Ί mastering-python-3-12-new-features-and-performance-improvements-7eef6a56c7ff
Mastering Python 3.12: New Features and Performance Improvements | by The Analytics Edge 🌟 | Medium
August 4, 2025 - The Python core team continues to optimize CPython’s interpreter. Python 3.12 introduces: Faster function calls by reducing overhead on argument parsing. Optimized frame evaluation for better stack management.
Discussions

performance - Why does it take longer to execute a simple for loop in Python 3.12 than in Python 3.11? - Stack Overflow
Python 3.12 was released two days ago with several new features and improvements. It claims that it's faster than ever, so I decided to give it a try. I ran a few of my scripts with the new version... More on stackoverflow.com
🌐 stackoverflow.com
Python 3.11 vs Python 3.12 – performance testing. A total of 91 various benchmark tests were conducted on computers with the AMD Ryzen 7000 series and the 13th-generation of Intel Core processors for desktops, laptops or mini PCs.
The results are... weird. Such a big difference between AMD and Intel is unexpected. More on reddit.com
🌐 r/Python
55
316
October 17, 2023
Python 3.12 vs Python 3.13 – performance testing. A total of 100 various benchmark tests were conducted on computers with the AMD Ryzen 7000 series and the 13th-generation of Intel Core processors for desktops, laptops or mini PCs.
Here is some click saving and the summary of the results: AMD Ryzen 7000 Series Desktop Processor Group of benchmarks Python 3.13 to Python 3.12 apps 1.06x faster asyncio 1.22x faster math 1.07x faster regex not significant serialize 1.05x faster startup 1.04x slower template 1.03x faster Result (geometric mean) 1.08x faster 13th Gen Intel Core Mobile Processor Group of benchmarks Python 3.13 to Python 3.12 apps 1.00x faster asyncio 1.19x faster math 1.06x faster regex 1.04x slower serialize 1.02x faster startup 1.01x slower template 1.02x slower Result (geometric mean) 1.05x faster More on reddit.com
🌐 r/programming
28
156
October 14, 2024
How does Python 3.13 perform vs 3.11 in single-threaded mode?
There are lots of different ways to measure performance. If you care about a specific workload, you'll have to benchmark it yourself. There are various resources that compare performance between different Python versions or describe optimization work: https://lost.co.nz/articles/sixteen-years-of-python-performance/ https://speed.python.org/ https://github.com/faster-cpython ← includes archives of benchmark results The TL;DR is that CPython tends to make performance improvements with every release, though individual benchmarks might see regressions. Historically, there was a large regression when switching to Python 3, but that is irrelevant now. Python 3.11 saw significant work on performance (reported as 25% average uplift in the release notes ). While you can expect Python 3.13 to be a bit faster, it focused on laying the groundwork for larger optimizations in the future (JIT, free-threaded mode). Those features are too experimental to be used in production, though. If you care about the last 5% of performance, I'd recommend compiling Python yourself with optimizations for your specific CPU architecture. Pre-built binaries tend to sacrifice a bit of performance for broader compatibility. More on reddit.com
🌐 r/Python
40
104
April 27, 2025
🌐
Reddit
reddit.com β€Ί r/python β€Ί python 3.12: a game-changer in performance and efficiency
r/Python on Reddit: Python 3.12: A Game-Changer in Performance and Efficiency
March 3, 2023 - All that's changing with 3.12 is adding a Path.walk method (which is welcome, to be fair). ... Python is taking steps towards improved multi-threaded parallelism by transitioning from a single global interpreter lock per process to a global interpreter lock per sub-interpreter. Does this mean multithreading will work more like multiprocessing now in general, performance-wise?
🌐
Flyaps
flyaps.com β€Ί update python 3.12: is it 2 times faster? key changes
Update Python 3.12: Is it 2 times faster? Key changes
June 17, 2025 - In Python 3.12, the isinstance() function for runtime protocol checks has significant improvements when checking protocols. Most isinstance() protocol checks should be at least twice as fast as in version 3.11, with some being up to 20 times ...
🌐
Phoronix
phoronix.com β€Ί news β€Ί Python-3.12-Released
Python 3.12 Released With Linux Perf Integration, Performance Improvements - Phoronix
Python 3.12 brings more flexible f-string parsing, support for the buffer protocol in Python code, a wide variety of performance improvements, integration support for the Linux perf profiler, new type annotation syntax for generic classes, and various other enhancements.
🌐
FB
engineering.fb.com β€Ί home β€Ί meta contributes new features to python 3.12
Meta contributes new features to Python 3.12 - Engineering at Meta
October 5, 2023 - In previous Python versions, all ... a single-use Python function object. In Python 3.12, PEP 709 inlines all list, dict, and set comprehensions for better performance (up to two times better in the best case)....
🌐
GitHub
github.com β€Ί faster-cpython β€Ί ideas β€Ί wiki β€Ί Python-3.12-Goals
Python 3.12 Goals Β· faster-cpython/ideas Wiki
March 3, 2023 - Improving the pyperformance benchmarking suite to include more representative real-world workloads. Assisting with CPython issues and PRs, in particular those that are related to performance.
Author Β  faster-cpython
🌐
Medium
medium.com β€Ί @spraneeth4 β€Ί from-python-3-10-to-3-12-specializing-adaptive-interpreter-delivers-real-world-performance-57b7712dbb97
From Python 3.10 to 3.12 : Specializing Adaptive Interpreter Delivers Real-World Performance | by praneeth_vvs | Medium
October 19, 2024 - This means it optimizes frequently used operations, adapting on-the-fly to boost performance without requiring any changes to your code. In essence, Python becomes smarter at runtime, executing code more efficiently.
🌐
Python
docs.python.org β€Ί 3.12 β€Ί whatsnew β€Ί 3.12.html
What’s New In Python 3.12
September 11, 2023 - The performance of writing to sockets in asyncio has been significantly improved. asyncio now avoids unnecessary copying when writing to sockets and uses sendmsg() if the platform supports it.
Find elsewhere
Top answer
1 of 1
17

I am able to reproduce the observed behavior between CPython 3.11.2 and CPython 3.12.0rc2 on Debian Linux 6.1.0-6 using an Intel i5-9600KF CPU. I tried to use a low-level profiling approach so to find the differences. Put it shortly: your benchmark is very specific and CPython 3.12 is less optimized for this specific case. CPython 3.12 seems to manage object allocations, and more specifically range a bit differently. CPython 3.12 appears to create a new object from the constant 2 for every iteration of the loop as opposed to CPython 3.11. Moreover, the main evaluation function do an indirect function pointer call which is particularly slow in this case. Anyway, you should not use (C)Python in such a use-case (this is stated in the CPython doc).


Under the hood

Here is the results I get (pretty stable between multiple launches):

3.11: 2.026395082473755
3.12: 2.4122846126556396

Thus, CPython 3.12 is roughly 20% slower than CPython 3.11 on my machine.

Profiling results indicates that half the overhead comes from an indirect function pointer call in the main evaluation function of CPython 3.12 which was not present in CPython 3.11. This function call is expensive on most modern processors. Here is the assembly code of the hot part:

       β”‚      ↓ je         4b8
  1,28 β”‚        mov        (%rdi),%rax
  0,33 β”‚        test       %eax,%eax
  0,61 β”‚      ↓ js         4b8
  0,02 β”‚        sub        $0x1,%rax
  2,80 β”‚        mov        %rax,(%rdi)
       β”‚      ↓ jne        4b8
  0,08 β”‚        mov        0x8(%rdi),%rax
 16,28 β”‚      β†’ call       *0x30(%rax)            <---------------- HERE
       β”‚        nop
  1,53 β”‚ 4b8:   mov        (%rsp),%rax
       β”‚        lea        0x4(%rax),%rcx
       β”‚        movzbl     0x3(%rax),%eax
  0,06 β”‚        mov        0x48(%r13,%rax,8),%rdx
  1,82 β”‚        mov        (%rdx),%eax
  0,04 β”‚        add        $0x1,%eax
       β”‚      ↓ je         8800

While the assembly code of the same function in CPython 3.11 is similar, it does not have such expensive call. Still, there are many similar indirect function calls like this already in CPython 3.11. My hypothesis is that such a call is more expensive in CPython 3.12 because it is less predictable by the hardware prediction unit (possibly because the same instruction calls multiple functions). For more information about that, please read this great post. I cannot say much more about this part since the assembly code is really HUGE (and it turns out the C code is also pretty big).

The rest of the overhead seems to come from the way object and more specifically constant are managed in CPython 3.12. Indeed, In CPython 3.11, PyObject_Free calls are slow (because you spent all your time creating/deleting objects), while in CPython 3.12, such a call is not even visible in the profiler, but there is instead PyLong_FromLong which is quite slow (not visible in CPython 3.11). The rest of the (many other) functions only takes less than 25~30% and look similar in the two versions. Based on that, we can conclude that CPython 3.12 creates a new object from the constant 2 for each iteration of the loop as opposed to CPython 3.11. This is clearly not efficient in this case (one should keep in mind that CPython is an interpreter and not a compiler though so it is not surprising it does not perform optimizations on this). There is a simple way to check that: store 2 in a variable before the loop and use this variable in the loop. Here is the corrected code:

import time

def calc():
    const = 2
    for i in range(100_000_000):
        x = i * const

t = time.time()
calc()
print(time.time() - t)

Here are the timings of the corrected code:

3.11: 2.045902967453003
3.12: 2.2230796813964844

The CPython 3.12 version is now substantially faster than before while the other version is almost unaffected by the modification of the code. At first glance, it tends to confirm the last hypothesis. That being said, the profiler still report many calls to PyLong_FromLong in the modified code! It turns out this change removed the issue related to the indirect function pointer call discussed in the beginning of this section!

My hypothesis is that the PyLong_FromLong calls are coming from a different way to manage the objects generated from range (i.e. i). The following code tends to confirm that (note the code require ~4 GiB of RAM due to the list so it should not be used in production but only for testing purposes):

import time

def calc():
    const = 2
    TMP = list(range(100_000_000))
    t = time.time()
    for i in TMP:
        x = i * const
    print(time.time() - t)

calc()

Here are results on my machine:

3.11: 1.6515681743621826
3.12: 1.7162528038024902

The gap is closer than before and the timings of the loop is smaller since objects are all pre-computed in the list before. Profiling results confirm PyLong_FromLong is not called in the timed loop. Thus, range is slower in this case in CPython 3.12.

The rest of the overhead is small (<4%). Such a performance gap can come from compiler optimizations or even very tiny changes in the CPython source code. For example, simple things like the address of conditional jumps can significantly impact performance results on many Intel CPUs (see: JCC erratum). Tiny details like this matters and compilers are not perfect. This is why such a variation of performance is common and rather expected so it's not worth investigating.

By the way, if you care about performance, then please use Cython or PyPy for such a computing code.

🌐
Lewoniewski
en.lewoniewski.info β€Ί 2023 β€Ί python-3-11-vs-python-3-12-performance-testing
Python 3.11 vs Python 3.12 – performance testing - Lewoniewski
October 21, 2023 - The result shows that Python 3.12 has the best performance results over Python 3.11 in the following tests: typing_runtime_protocols (2.99x faster), generators (1.55x faster), asyncio_tcp (1.49x faster).
🌐
Medium
medium.com β€Ί @backendbyeli β€Ί python-3-13-vs-3-12-why-upgrading-improves-productivity-f53802557df5
Python 3.13 vs 3.12: Performance & Productivity Gains | Medium
November 13, 2025 - Discover Python 3.13's JIT compiler, improved error messages, and performance gains. Learn why upgrading from 3.12 boosts backend development productivity today.
🌐
Medium
medium.com β€Ί @HeCanThink β€Ί python-3-12-more-faster-and-more-efficient-python-b636f00b0471
Python 3.12: More Faster and More Efficient Python πŸƒ | by Manoj Das | Medium
May 3, 2023 - However, recent efforts have focused on streamlining object design to achieve more efficient memory utilization. In Python 3.12, a major breakthrough has been achieved by reducing the object header size from 208 bytes to a mere 96 bytes.
🌐
HackerNoon
hackernoon.com β€Ί python-312-overview-past-limitations-faster-cpythons-advent-and-the-excitement-of-new-versions
Python 3.12 Overview: Past Limitations, Faster CPython's Advent, and the Excitement of New Versions | HackerNoon
November 1, 2023 - Focused on turbocharging Python's performance, CPython aimed to not only address the age-old speed concerns but also navigate through a spectrum of issues.
🌐
DEV Community
dev.to β€Ί maximsaplin β€Ί python-312-performance-a-quick-test-4en5
Python 3.12 Performance - a Quick Test - DEV Community
December 7, 2023 - Yet another confirmation of tradeoffs brought by Python - a super convenient glue language which is super slow in computation tasks. P.S.: I have come across this more holistic comparison of 3.12 to 3.11. It had run pyperformance 1.0.9 on AMD Ryzen 9 7900 and Intel Core i3-1315U, both are x86 CPUs.
🌐
Medium
medium.com β€Ί @reeceml β€Ί will-python-3-12-be-faster-cab5fc2d3fb1
Will Python 3.12 be faster? | by Reece Miller | Medium
December 16, 2023 - One of the key focuses of Python 3.12 is to improve the overall performance and speed of the language.
🌐
InfoWorld
infoworld.com β€Ί home β€Ί software development β€Ί programming languages β€Ί python
Python 3.12: Faster, leaner, more future-proof | InfoWorld
June 25, 2024 - Shannon outlined how as of Python 3.12, the object header’s now a mere 96 bytesβ€”slightly less than half of what it was before. These changes don’t just allow more Python objects to be kept in memory, they also improve cache locality for Python objects.
🌐
Python
python.org β€Ί downloads β€Ί release β€Ί python-31210
Python Release Python 3.12.10 | Python.org
Many large and small performance improvements (like PEP 709 and support for the BOLT binary optimizer), delivering an estimated 5% overall performance improvement. New type annotation syntax for generic classes (PEP 695).
🌐
Analytics Vidhya
analyticsvidhya.com β€Ί home β€Ί python 3.12 – new features and improvements
Python 3.12 – New Features and Improvements
May 21, 2024 - Python 3.12 introduces a host of ... and developer experience. From a refined type parameter syntax to improvements in error messages and enhancements across various modules, Python 3.12 strengthens ......