What’s New in Python Docs
More at Real Python
What’s New in Python Docs
More at Real Python
00:00
The previous lesson covered Python 3.10 and 3.11 including the match
case
statement. This lesson covers Python 3.12 and 3.13 and the performance improvements therein.
00:12 Python 3.12 was one of those releases that concentrated on internals. For example, the old parser wasn’t actually capable of parsing the mini-language used inside of f-strings.
00:22 As a result, there was a small parser inside of the parser for handling them. The PEG parser is capable of handling f-strings, and so to simplify the interpreter’s code f-string parsing was moved to the PEG. At the surface level,
00:36 you likely wouldn’t notice this, but it did add some capabilities like being able to nest f-strings. Nobody said you should, but you can. You may also have heard of the GIL that stands for the Global Interpreter Lock, and it’s a resource management lock to ensure there aren’t race conditions during memory management.
00:54 This is an implementation detail of CPython, and it puts an upper limit on just how concurrent you can get with multithreaded code as the threads themselves still have to wait on the lock’s release.
01:06 Python 3.12 made the GIL a tiny bit less global. CPython actually supports multiple interpreters, and these can be used when Python calls down into C code.
01:16 By moving the GIL into these multi-interpreters, instead of having one across them, two different C libraries in theory wouldn’t have to wait for each other.
01:25 On the topic of things that are a little easier to explain, there were even more error message improvements and more dead battery removal in this release. This is around the time there were a lot of conversations around performance and possibly removing the GIL altogether, so there was a lot of internal changes made to clean up in prep for this work in the 3.12 release.
01:47 To learn more about the changes in 3.12, once again, you’ve got your choice of course, tutorial or podcast.
01:54 So with Python 3.13, we looked at another way of removing the GIL here with experimental free threading. Continuing this idea of like what are different ways that we can speed up Python, and it’s your first chance to kind of try this out in kind of a parallel way of working in Python.
02:12 You can run it in this separate mode. Along with that, there is an experimental just-in-time compiler, experimental JIT that you can explore also in Python 3.13. The error messages continue to improve and they improve the REPL, which came with Python.
02:32 If you install Python from python.org and go into the standard REPL, you’ll see improvements of the colors along with the error messages and lots of other functionality.
02:46 If you want to learn more, instead of an OR statement here, I’ll say an AND statement. You can read the tutorial and you can watch the video course by Mr.
02:55 Trudeau. Along with that, you can also listen to us discuss it in detail on the podcast.
03:03 Next up, the last lesson, a little sneak peek of what’s happening in Python 3.14, scheduled for the fall of 2025.
Become a Member to join the conversation.