Python 3.11 is here and it's fast
Episode #388,
published Wed, Nov 2, 2022, recorded Fri, Oct 28, 2022
Python 3.11 is here! Keeping with the annual release cycle, the Python core devs have released the latest version of Python. And this one is a big one. It has more friendly error messages and is massively faster than 3.10 (between 10 to 60% faster) which is a big deal for a year over year release of a 30 year old platform.
On this episode, we have Irit Katriel, Pablo Galindo Salgado, Mark Shannon, and Brandt Bucher all of whom participated in releasing Python this week on the show to tell us about that process and some of the highlight features.
On this episode, we have Irit Katriel, Pablo Galindo Salgado, Mark Shannon, and Brandt Bucher all of whom participated in releasing Python this week on the show to tell us about that process and some of the highlight features.
Episode Deep Dive
Guests introduction and background
- Irit Katriel – A Python core developer who contributed to Python 3.11’s new exception features, including exception groups and contextual error notes.
- Pablo Galindo Salgado – The release manager for Python 3.10 and 3.11, a member of the Python Steering Council, and a core developer overseeing the annual release process. He’s also known for live-streaming the actual cpython release process.
- Mark Shannon – A long-standing Python core developer and the technical lead of the Faster CPython team at Microsoft, which significantly contributed to the performance improvements in Python 3.11.
- Brandt Bucher – Also on the Faster CPython team, working on the specialized adaptive interpreter and other performance optimizations. He joined the show to talk about these major speed enhancements and tools like his
specialist
package that help visualize CPython’s new optimizations.
What to Know If You're New to Python
Here are a few points to help you follow the conversation and new features in 3.11:
- Python 3.11 introduces more helpful and clear error messages so you can debug and learn more easily.
- There’s a strong focus on improved performance that can benefit your programs without changing your code.
- Python’s exception handling has new capabilities (like exception groups) making more complex error handling scenarios easier.
- If you’re new, just know that upgrading to Python 3.11 will often give you speed boosts and better debugging right away.
Key points and takeaways
- Major Performance Improvements in Python 3.11
Python 3.11 can be 10–60% faster (or more) for pure-Python code, thanks to the work of the Faster CPython team. Even though results vary by workload, many real-world applications will see significant benefits without code changes. The specialized adaptive interpreter (PEP 659) dynamically modifies bytecode to optimize repeated operations like global variable lookups. All of this adds up to an impressively faster Python experience.
- Links and tools:
- Live Streaming the Release Process
Pablo Galindo Salgado live-streamed the final steps of Python’s release, giving the community a rare, transparent look at how “the sausage is made.” This behind-the-scenes look revealed all the details, commands, and inevitable drama of releasing a new Python version. Viewers also got insights from other Python core developers as they explained new features and overcame last-minute technical hiccups (like a broken YubiKey!).
- Links and tools:
- Exception Groups and
except\*
One of the standout new language features is exception groups, enabling multiple exceptions to be reported together when multiple tasks fail concurrently (e.g., async tasks). Withexcept*
, you can handle subsets of exceptions separately without losing track of all the errors that occurred. This is particularly useful for asyncio, Trio, or any multi-task scenario.- Links and tools:
- Zero-Cost Exceptions and Frame Optimization
Python 3.11 introduced “zero-cost exceptions,” meaning that if no exception is raised, you pay almost no overhead for the possibility of errors. The internal frame structure has been slimmed down, so function calls are also more memory-friendly and faster overall. Exception handling remains flexible but is far more efficient under normal (non-error) execution paths.
- Links and tools:
- Fine-Grained Error Locations (PEP 657)
Python 3.11’s improved tracebacks underline the exact portion of code that triggered the exception. This is especially helpful if you have multiple dictionary or list accesses in a single line, so it’s clear which one actually failed. Pablo and his team even added logic that re-parses part of the AST to highlight sub-expressions precisely.
- Links and tools:
- Adding Notes to Exceptions (PEP 678)
You can now attach extra context to exceptions with the
add_note()
method. Whether you’re writing libraries or debugging a tricky scenario, this small feature can be invaluable for clarifying why an error might have occurred or providing helpful suggestions for corrective action.- Links and tools:
specialist
: Visualizing Bytecode Specialization Brandt Bucher’sspecialist
tool can show exactly which sections of your code become specialized and which do not. The tool creates colorized HTML output indicating adaptive optimizations, letting you see precisely where Python 3.11’s speedups apply (or fail to apply). It’s a fantastic resource for performance tuning and curiosity-driven exploration.- Links and tools:
- Memory Profilers and Other Performance Tools
In the discussion, the guests mentioned various third-party packages that help you dig deeper into performance. For example, the
memory
profiler is one way to find where your code uses large amounts of memory, andscalene
is another tool for CPU and memory profiling in Python. All these tools fit nicely with Python 3.11’s performance push.- Links and tools:
- New Features for AsyncIO
Python 3.11 introduces task groups as well as these improved exception capabilities, directly benefiting asynchronous code. Structured concurrency becomes simpler, making your async tasks easier to manage and debug when multiple exceptions occur.
- Links and tools:
- TOML Support and Other Smaller Highlights
Python 3.11 includes a built-in
tomllib
for parsing TOML data (commonly used in project configuration). Additionally, the release includes new regular expression features (like atomic grouping) and other type-hint enhancements. While not as flashy as big performance wins, these additions streamline workflows for many Python developers.
- Links and tools:
Interesting quotes and stories
- Pablo on release-day drama: “It’s not glamorous, it’s long, it’s complicated, but I decided to live stream it anyway—somehow people still enjoy seeing me push the actual release buttons, fix last-minute issues, and occasionally break GitHub!”
- Mark’s long quest for speed: “It’s been a dream for me since around 15 years ago to make Python faster in a structural way—so 3.11 is kind of a culmination of that plan, but we’re still pushing forward!”
Key definitions and terms
- Specializing Adaptive Interpreter: A new Python 3.11 mechanism (PEP 659) that dynamically changes bytecode for better performance on repeated operations.
- Exception Groups: Lets Python handle multiple errors collectively using
except*
. This is especially powerful when asynchronous tasks fail concurrently. - Zero-Cost Exceptions: A technique to reduce overhead of exception handlers when no errors are actually thrown.
- Fine-Grained Error Locations: More precise traceback highlighting from PEP 657, showing exactly which sub-expression caused an error.
Learning resources
If you’d like to deepen your Python skills—especially around modern releases—here are a few resources.
- Python for Absolute Beginners: A comprehensive intro to Python fundamentals if you're just getting started.
- Python 3.11: A Guided Tour Through Code: A deep dive into new Python 3.11 features through hands-on examples, perfect if you want to explore the additions discussed in this episode.
Overall takeaway
Python 3.11 is one of the most substantial updates to the language in years, bringing speed boosts, clearer error reporting, and better async error handling. Beyond just the major performance gains, new features like exception groups, add_note()
, and advanced traceback highlighting improve the development experience. Whether you’re brand new to Python or an experienced developer, this release delivers upgrades that will make coding more fun, efficient, and productive.
Links from the show
Guests
Irit Katriel: @iritkatriel
Mark Shannon: linkedin.com
Pablo Galindo Salgado: @pyblogsal
Brandt Bucher: github.com
Python 3.11.0 is now available: blog.python.org
PEP 101 - Releasing Python: peps.python.org
PEP 678 – Enriching Exceptions with Notes: peps.python.org
PEP 654 – Exception Groups and except*: peps.python.org
PEP 657 – Include Fine Grained Error Locations in Tracebacks: peps.python.org
Python Buildbot: python.org
Making Python Faster Talk Python Episode: talkpython.fm
Specializing, Adaptive Interpreter on Talk Python: talkpython.fm
Specialist Visualizer: github.com
"Zero cost" exception handling: github.com
Pyodide: pyodide.org
pyscript: pyscript.net
Watch this episode on YouTube: youtube.com
Episode transcripts: talkpython.fm
--- Stay in touch with us ---
Subscribe to Talk Python on YouTube: youtube.com
Talk Python on Bluesky: @talkpython.fm at bsky.app
Talk Python on Mastodon: talkpython
Michael on Bluesky: @mkennedy.codes at bsky.app
Michael on Mastodon: mkennedy
Irit Katriel: @iritkatriel
Mark Shannon: linkedin.com
Pablo Galindo Salgado: @pyblogsal
Brandt Bucher: github.com
Python 3.11.0 is now available: blog.python.org
PEP 101 - Releasing Python: peps.python.org
PEP 678 – Enriching Exceptions with Notes: peps.python.org
PEP 654 – Exception Groups and except*: peps.python.org
PEP 657 – Include Fine Grained Error Locations in Tracebacks: peps.python.org
Python Buildbot: python.org
Making Python Faster Talk Python Episode: talkpython.fm
Specializing, Adaptive Interpreter on Talk Python: talkpython.fm
Specialist Visualizer: github.com
"Zero cost" exception handling: github.com
Pyodide: pyodide.org
pyscript: pyscript.net
Watch this episode on YouTube: youtube.com
Episode transcripts: talkpython.fm
--- Stay in touch with us ---
Subscribe to Talk Python on YouTube: youtube.com
Talk Python on Bluesky: @talkpython.fm at bsky.app
Talk Python on Mastodon: talkpython
Michael on Bluesky: @mkennedy.codes at bsky.app
Michael on Mastodon: mkennedy