Python 3.13 performance analysis on the AMD Ryzen processor
Python 3.13 has arrived, bringing with it a host of new features and performance optimizations. As developers eagerly anticipate the improvements, it's essential to understand how this latest version stacks up against its predecessor, Python 3.12. This article provides a comprehensive analysis of Python 3.13's performance based on benchmark tests conducted using the pyperformance 1.11.0 library.
Benchmark Setup
All tests were executed on Windows 11 computers equipped with an AMD Ryzen 9 7900 processor, DDR5 RAM, and an M.2 PCIe Gen4 NVMe drive. The benchmarks utilized the pyperformance 1.11.0 library and compared Python 3.12.7 with Python 3.13.0, both 64-bit versions.
Overall Results
The benchmarks reveal that Python 3.13 is, on average, 1.08x faster than Python 3.12. This represents an 8% performance improvement, showcasing Python's continuous efforts to enhance efficiency and speed.
Detailed Benchmark Analysis
Significant Performance Improvements
- async_tree_eager_io_tg: 1.61x faster
- async_tree_eager_io: 1.54x faster
- async_tree_io_tg: 1.54x faster
These benchmarks are part of the async_tree family, which evaluates asynchronous workloads involving tree structures with various operations at the leaf nodes.
Understanding the async_tree benchmarks
The async_tree benchmarks assess the performance of asynchronous operations using asyncio.gather() on a tree structure that's six levels deep with six branches per level. The leaf nodes simulate different workloads depending on the variant:
- async_tree: No actual asynchronous work at the leaf nodes.
- async_tree_io: Leaf nodes simulate asynchronous I/O operations (e.g.,
asyncio.sleep(50ms)). - async_tree_memoization: Leaf nodes perform asynchronous I/O with 90% memoization.
- async_tree_cpu_io_mixed: Half the leaf nodes perform CPU-bound tasks (like
math.factorial(500)), and the other half perform asynchronous I/O.
These benchmarks also have an "eager" flavor that uses the asyncio eager task factory if available. The significant speedups in these benchmarks suggest that Python 3.13 has made substantial optimizations in handling asynchronous I/O operations, which is excellent news for developers working with async code.
Other Notable Improvements
- comprehensions: 1.37x faster
- unpack_sequence: 1.17x faster
- deltablue: 1.19x faster
These benchmarks test core language features like list comprehensions, sequence unpacking, and constraint-solving algorithms. The improvements indicate enhancements in Python's interpreter efficiency and execution speed for fundamental operations.
Performance Regressions
While Python 3.13 shows impressive gains, some benchmarks exhibited slower performance compared to Python 3.12:
- coverage: 1.36x slower
- create_gc_cycles: 1.13x slower
- regex_v8: 1.13x slower
Understanding the regex_v8 benchmark
The regex_v8 benchmark is a Python port of V8's regular expression benchmark. It involves loading 50 of the most popular web pages and logging all regex operations performed. Each operation is weighted based on page popularity and execution frequency. The data is encoded using ROT13 to preserve the matching characteristics without revealing the actual content.
The slight regression in the regex_v8 benchmark suggests that there may have been changes in Python's regular expression engine or interpreter that impact performance. Developers relying heavily on regex operations might want to benchmark their specific use cases when considering an upgrade.
Group-wise Performance Analysis
Examining benchmarks by groups provides additional insights:
- asyncio: 1.22x faster
- apps: 1.06x faster
- math: 1.07x faster
- serialize: 1.05x faster
- template: 1.03x faster
- startup: 1.04x slower
- regex: Not significant
The most significant improvement is in the asyncio group, aligning with the individual async_tree benchmarks' performance gains. The slight slowdown in the startup group suggests that Python 3.13 may have a marginally longer startup time, which could be relevant for short-lived scripts or command-line tools.
Conclusion
Python 3.13 brings notable performance improvements over Python 3.12, particularly in asynchronous operations and core language features like comprehensions and sequence unpacking. While there are areas with regressions, such as startup time and specific modules like decimal, the overall enhancements make Python 3.13 a compelling upgrade for many developers.
Full report is available on en.lewoniewski.info

Comments
Post a Comment