October 25th, 2024

Python 3.13, what didn't make the headlines

Python 3.13 features improvements in PDB, bug fixes in shutil, and new annotation syntax for comprehensions and lambdas, but overall performance gains are minimal and some deprecated features may disrupt existing code.

Read original articleLink Icon
Python 3.13, what didn't make the headlines

Python 3.13 has introduced several notable improvements and features, although it has not significantly increased performance. Key enhancements include a revamped PDB (Python Debugger) with multiline editing, code completion, and better error handling. The shutil module has received numerous bug fixes, making file system operations more reliable. Additionally, the new annotation syntax now supports comprehensions and lambdas, expanding its usability. While there are small victories in concurrency with asyncio improvements, the overall performance gains are minimal, similar to the previous version. Some deprecated features and changes may disrupt existing code, such as alterations to Path.glob() and the removal of certain context manager functionalities. Despite these challenges, Python 3.13 focuses on refining existing features, enhancing error messages, and improving documentation, indicating a commitment to maintaining a stable and user-friendly environment for developers.

- Python 3.13 introduces significant improvements to PDB, enhancing debugging capabilities.

- The shutil module has been updated with bug fixes, making file operations more reliable.

- New annotation syntax allows for greater flexibility with comprehensions and lambdas.

- Performance improvements in Python 3.13 are minimal, similar to version 3.12.

- Some deprecated features may cause compatibility issues with existing code.

Link Icon 2 comments
By @sgarland - 7 months
I feel like (by which I mean, in my tests for personal projects) performance peaked with 3.11, and has been going downhill since.

For example, 3.12 changed the byte code list comprehensions use, citing faster performance. In my tests, this is only true with small lists, and as soon as you get to a large number of items (~10K), it falls off a cliff. While large lists are probably not the norm, to have that completely ignored is maddening.

The 3.13 REPL is nice, I’ll give them that.

By @zahlman - 7 months
>Python 3.13 is still not significantly faster. Sorry.

Unsurprising. Attention to internals has been split by the GILectomy - I guess some people expected automatic gains from that, but that seemed unwarranted to me. It's normal for performance improvements in Python to be incremental (also in terms of memory efficiency - e.g. https://github.com/zahlman/python-dict-stats/), with here and there a big gain for a specific task (e.g. `math.factorial` getting a better algorithm in 3.x - https://stackoverflow.com/questions/9815252).

There also isn't generally a huge amount of pressure for these kinds of optimizations, given typical Python use cases. People who need performance are often already using a Python binding to code written in another language anyway.

> Ditto for zipfile.Path, a pathlib-compatible wrapper for traversing zip files you didn't know existed since 3.8. And you didn't know it because it sucked, frankly. But 3.13 brings many QoL patches to it, and improves a lot on how it handles directories, which used to require a lot of manual labor. So I expect it will see more use from now on.

It'd be nice if the various archive-handling libraries offered more of a common interface, including that sort of wrapper. BTW, Barney Gale (the dev primarily responsible for `pathlib`) is relatively active on https://discuss.python.org and generally a joy to talk with.