Navigation
Recherche
|
What you need to know about Python 3.14’s faster interpreter
lundi 10 février 2025, 19:20 , par InfoWorld
Python 3.14, due out later this year, is set to receive a new type of interpreter that can boost performance by up to 30% with no changes to existing code.
The CPython 3.14 change log describes the feature as “a new type of interpreter based on tail calls.” This description may be a little misleading for those who don’t closely follow internal Python development work. “Tail calls” doesn’t mean that CPython, or the Python language, will now support tail call optimization. It refers to an optimization that a C compiler performs on the CPython code, which speeds up the way the interpreter dispatches its bytecode instructions. No changes to existing Python code are required, and C extension modules for CPython don’t need to be recompiled either, as there are no changes to the CPython APIs or ABIs. Nor does the new interpreter add significant maintenance overhead to CPython, as it’s been implemented mainly by repurposing existing code. For those who use prebuilt CPython binaries, the new interpreter build should be included as part of the upgrade process to Python 3.14. If you build CPython from source, though, using this feature will require a specific compilation flag for the CPython build process (--with-tail-call-interp). Most crucially, the new interpreter requires using a C compiler that supports the tail call optimization. Not all C compilers provide such support. However, as of this writing, the compilation process is supported on MSVC and on Clang 19 or better (on x86-64 and AArch64 architectures). It is expected to be added to GCC as well. Python runs more slowly than machine-compiled languages like Rust or C/C++, in big part because the behaviors of the language make it hard to optimize for speed. But that hasn’t stopped massive efforts to make Python faster without sacrificing backwards compatibility. Most of those efforts focus on optimizing the CPython interpreter to do less work—for instance, by using specialized opcodes and other just-in-time optimizations. Some of these optimizations yield only marginal, incremental speedups. But many of these speedups work cumulatively. And some of these optimizations, like the tail-call optimization described here, can provide significant performance boosts across the board. The most common theme in these CPython improvements is how they enhance performance at no cost to the user apart from upgrading the interpreter. Python’s broad user base and rich library ecosystem mean that any performance optimizations best serve the Python world when they don’t break backwards compatibility. The first beta release of Python 3.14, which will allow testing of the new interpreter, is scheduled for May 2025. Interim alpha releases also should include the new interpreter.
https://www.infoworld.com/article/3820890/what-you-need-to-know-about-python-3-14s-faster-interprete...
Voir aussi |
56 sources (32 en français)
Date Actuelle
mar. 11 févr. - 14:56 CET
|