Python 3.13 has officially been released as of October 7, 2024! This was far from unexpected after Python 3.12 was released in October 2023, and Python 3.11 was released in October 2022. But, with these annual releases, have there actually been any performance improvements?
Let’s take a look! In this article, we’ll cover everything new in Python 3.13, as well as any ways that they have improved on previous Python versions. Some highlights from this version of Python include:
- Experimental Just-In-Time (JIT) compiler for accelerated code execution.
- Free-threaded CPython build, removing the Global Interpreter Lock (GIL) for true multi-threading.
- Overhauled REPL with syntax highlighting, improved prompts, and smarter auto-completions.
- Improved error messages with more descriptive and helpful suggestions.
- Expansion of the typing module with features like TypeIs, ReadOnly, and default values for TypeVar.
- Consistent mutation semantics for locals() have been defined across contexts.
- Outdated or deprecated modules were removed from the standard library.
- Better support for mobile platforms, including better cross-compilation tools for iOS and Android.
Python programs are incredibly powerful, and keeping up with the latest version is the best way to make sure you’re writing code as clearly and efficiently as possible. If you want a developer who is up to date with the latest version of Python, you’re in the right place.
At Trio, we help many companies augment their development teams or outsource all of their Python code to experienced developers who are up to date on the latest technology and best practices. Our developers are already vetted and have proven themselves in countless projects, making hiring simple.
Let’s jump into the best new features you can make use of in 2025.
Major New Features in Python 3.13
What’s new in Python? Well, this version of Python 3.13 introduces a variety of new features that will result in changes to your code. It is probably best to start with the major new features and improvements before looking at the minor changes.
New Interactive Interpreter (REPL)
One of the biggest improvements is in the Python interpreter. New features have been released that make it a lot easier for Python developers to code quickly and efficiently. This includes syntax highlighting, better prompts, and contextual auto-completions. All of this is invaluable in promoting productivity in the command line.
You’ll pick up on these changes very quickly when you start to write new code. For example, if you type a simple print(“Hello”),you’ll notice that there are now different colors, similar to an IDE. This makes catching errors easy.
The command history navigation is also a lot better, making it easier for developers, or even entire Python teams, to access previously entered lines.
Improved Error Messages
Developer-friendly diagnostics have always been one of the biggest features of the Python programming language. Since Python 3.13 was released, this trend continues.
Error messages are more descriptive and more actionable, making it easier to find the location of your mistakes and debug effectively.
For example, previous misspellings would have resulted in the following error message:
NameError: name ‘misspelledvariable’ is not defined
You’ll also get a recommendation for the new version of Python:
NameError: name ‘misspelledvariable’ is not defined. Did you mean ‘variable’?
This suggestion is made thanks to the use of Levenshtein distance algorithms, which still function well in large codebases with many similarly named variables.
Free-Threaded CPython: The No-GIL (Global Interpreter Lock) Revolution
There is now experimental support for a free-threaded CPython build. This allows for the removal of the Global Interpreter Lock. But why is this one of the most transformative of the latest features introduced in Python 3.13? It opens the door to true multi-threading and concurrency!
The result of being able to conduct multiple tasks at once is incredible responsiveness in applications, as well as scalability, like the kind needed to build an operating system.
Since this is so new, and very much in the experimental phase, developers can try compiling Python without the GIL at configuration using —disable-gil.
Here’s how to try it:
./configure –disable-gil
make
You can then test the benefits by running a multi-threaded script. This will allow you to see if you can produce any performance improvements in CPU core bound tasks such ass reduced execution time thanks to threads running in parallel.
Here’s an example of what that will look like:
import threading
import time
def compute():
for _ in range(10**7):
pass
threads = [threading.Thread(target=compute) for _ in range(4)]
start = time.time()
for t in threads: t.start()
for t in threads: t.join()
print(“Elapsed:”, time.time() – start)
Experimental JIT Compiler
The Just-In-Time compiler is another experimental addition added to the new Python version. When it’s enabled, the new JIT compiler translates Python bytecode into machine code at runtime. The result, in theory, is faster execution.
Although there has been no stable release of the python JIT compiler, and it is very much still in the early stages of development, it could close a major performance gap between Python and some other languages.
Here’s how you would set the environment variable to try it out:
PYTHONJIT=1 python3.13
To make sure that it is working correctly, check the difference in execution time in pieces of code that are particularly compute-heavy. Our developers have found that even small speedups from the JIT can really add up in high-volume applications.
import time
start = time.time()
sum(i * i for i in range(10**7))
print(“Elapsed:”, time.time() – start)
Static Typing Improvements
The static typing system is not a new Python release, but it has been significantly improved to become more powerful and expressive in this version. New additions like typing.TypeIs helps with runtime type narrowing while typing.ReadOnly introduces support for immutability annotations.
These features not only enhance general code safety but also assist with collaboration on large teams.
Here’s how you might use TypeIS for better type checking:
from typing import TypeIs
def is_str(val: object) -> TypeIs[str]:
return isinstance(val, str)
def handle(val: object):
if is_str(val):
# val is now inferred as str
print(val.upper())
And here’s how you would use ReadOnly to ensure values shouldn’t be reassigned:
from typing import ReadOnly
config: ReadOnly[dict[str, str]] = {“env”: “production”}
# config[“env”] = “staging” # Error in static type checkers
Defined Mutation Semantics for locals()
You could always implement locals() to return a dictionary. However, modifying this dictionary has had unclear results that were greatly affected by the context. The changes in the latest Python version mean that the semantics of these mutations have now been formalized, providing a more predictable and consistent result.
This consistency is crucial for developers who rely on dynamic manipulation of local variables.
Here’s what it might look like to make the code behave more consistently, improving dynamic code generation and metaprogramming:
def example():
locals()[‘x’] = 10
print(x) # Raises NameError in 3.12, defined behavior in 3.13
Mobile Platform Support
One big improvement has been the gradually expanding reach into mobile development, with new Python 3.13 improvements in iOS and Android support. Our developers have noted that a major component of this improvement has been in terms of cross-compilation tools and configuration options that make Python suitable for new projects.
In these Python-powered mobile apps, developers would need fewer workarounds, which would mean easier packaging. BeeWare and Kivy are two great options at the moment, and will both allow projects to benefit from more reliable builds and cleaner integration with system libraries.
Other Language & Syntax Changes
Beyond the major changes that have come with the newest release of the Python programming language, there have been several small adjustments and improvements that may also impact you.. For example, one of the many changes to the languages is that developers can now use copy.replace() to manipulate immutable objects:
from copy import replace
from dataclasses import dataclass
@dataclass(frozen=True)
class Config:
timeout: int
config = Config(timeout=30)
new_config = replace(config, timeout=60)
print(new_config) # Config(timeout=60)
There is also new support for naked docstrings, which lets developers maintain cleaner syntax in classes and modules. Exception handling has also been improved, and chained exceptions can now be made clearer and help with debugging.
Module Updates and Improvements
Taking a deeper look, we’re able to see that there have been numerous changes to the standard library that not only make it easier to use Python, but also ensure better performance.
Newly Introduced Modules
One of the newest additions to the standard library is tomllib, which makes it possible to read TOML files commonly used for configuration. This eliminates the need for third-party dependencies.
Our developers think this is going to be especially useful for parsing pyproject.toml files, like you could in ecosystems like Rust. Here’s how that would look:
import tomllib
with open(“pyproject.toml”, “rb”) as f:
config = tomllib.load(f)
print(config[“tool”][“poetry”][“name”])
Updated Standard Library Modules
The updates to most of the libraries have not only enhanced functionality, but also increased compliance standards. Many of these changes also allow for modernized APIs. This is critical in fields like data security, fintech, healthcare, and a variety of other industries where Python apps are being used. Some of the most notable updates are:
- asyncio
- argparse
- pathlib
- math
- typing
When looking at asyncio, we’re glad to see that it now offers better debugging support and faster event loop execution. There are many benefits that will result from this, but the ultimate result is reduced latency in coroutine-heavy apps. Improved error visibility will also help developers debug code faster.
The changes to argparse include more intuitive subparser handling and improved error messages, simplifying development, especially in complex command-line interfaces.
Updates to the email module will improve compliance with RFC 5322 (which specifies Internet Message Format), and enhance the parsing of complex headers and MIME parts. This makes the communications more compatible with modern client expectations and industry standards.
Enhancements made to pathlib improve path resolution. They also provide new methods of working with both URIs and URLs.
There have been two major additions to the math module in the latest release of Python. These include the addition of math.tau and better support for mathematical edge cases. The latter is particularly relevant in scientific computing.
We’ve already mentioned some of the alterations to typing above. These include the now available ReadOnlyand TypeIs, and they allow default values for TypeVar. All of this enables more expressive and safe type annotations.
Removed and Deprecated Modules
While many new modules have been added, many outdated or deprecated modules have also been removed. The aim is to comply with the efforts mentioned in PEP 594 (Python Enhancement Proposals) in an effort to maintain compatibility with newer versions of Python and reduce the overall maintenance required.
Many modules have been fully removed in this version, including:
- aifc
- chunk
- cgitb
- macpath
- msilib
- nntplib
- optparse
- pipes
- sndhdr
- spwd
- sunau
- telnetlib
- uu
- xdrlib
As mentioned above, these are considered outdated or legacy features. Often, you’ll see them referred to as “dead batteries”.
If you are using any of these modules, you are going to have to move over. The sooner you can do so, the better. In many cases, you may be able to move over to an alternative module provided in the standard library, but in some cases, it is possible that you are going to need to integrate with third-party packages.
If you aren’t sure of how to do this, we can provide you with a seasoned Python expert to temporarily augment your team and help you update any existing code. Trio’s experts have been able to stay at the forefront of the industry, and have devoted time to continued learning.
When updating your code, consider moving to alternatives for modules that have not yet been removed but are deprecated in Python 3.13 and scheduled for removal later.
Some deprecated modules include smtpd, distutils, cgi, formatter, mailcap, imghdr, and ossaudiodev.
CPython Internals and Developer-Focused Changes
Developer-focused changes will affect everyone from extension authors to performance tuners and even those who contribute to Python itself. While the updates are important to make the ecosystem more maintainable and efficient, it is important to know about them and adjust accordingly.
Bytecode Optimizations
Bytecode is optimized in almost every version of Python to reduce the number of instructions per operation. The result is streamlined execution.
Some of the optimizations we’ve seen in this interaction include instruction selection, reordering opcodes, and eliminating redundant load/store operations. These changes are often quite subtle; they can result in major changes over a large codebase, as we have already mentioned above.
C API Changes
There have been a couple of changes to the existing C API, or the API used by C and C++ programmers. The idea is to give developers more control over how the interpreter behaves and improve memory management.
For example, PyInterpreterConfig, PyThread_tss_alloc(), and PyThread_tss_free() have all been added to initialize interpreters or provide safer APIs for managing thread-local storage, respectively.
Some legacy C APIs have also been officially marked as deprecated. PyEval_CallObjectWithKeywords() and PyParser_SimpleParseFile() are two such examples. In most cases, these functions have been replaced by far better options.
Build & Regression Test Changes
The build system has changed slightly, making it more suitable for cross-platform consistency. Configuration across a variety of platforms has been simplified, including embedded and mobile environments.
There are some new CMake options, and a lot of the tooling has been updated with an emphasis on reproducibility.
The regression test framework has also been modernized so that tests are faster and support better isolation, making them better for CI/CD pipelines.
Real-World Impact & Developer Guidance
We’ve covered most of the technical aspects, and now it’s time to look at how this is going to impact you practically and everything you should consider before deciding to move over.
Should You Upgrade to Python 3.13?
If you are building tools that heavily rely on concurrency, performance, or advanced typing features, then it’s probably a good idea to upgrade to the latest version of Python. This is an even better idea if you use multi-threading or asynchronous scaling at all.
You need to consider if your dependencies are fully compatible, though carefully. Getting an expert on board can help you evaluate whether your apps could move over, and if it would be worth the trouble.
For most developers, especially if you are working on smaller apps or experimenting with Python as a hobby, you don’t necessarily need to make the move each year. Instead, consider experimenting or testing under Python 3.13 in parallel with an existing version. Just make sure that you don’t fall too far behind.
Compatibility and Migration Notes
One of the biggest considerations you need to make is the changes between versions that will result in your app ‘breaking’. These include the removal of any legacy standard library modules, like those we discussed above, and changes to models like locals(), which will affect your dynamic code, and adjustments in the C API that might break older C extensions.
So, how do you test your code to make sure your migration is going well?
First, you need to run your full test suite under the new version, using both the default and no-GIL builds. Then you can use tools like tox to automate compatibility testing across multiple versions.
If you notice things aren’t quite working as you expected, analysis tools like pyupgrade and pylint can be used to find any deprecated syntax and APIs. Don’t forget to test C extension modules as well!
If you need to find a Python developer for your apps, look no further. At Trio, we hire the top 1% of all applicants, taking only the best of the best. We’ll connect you to the right person in a matter of days, saving you time and money. Reach out to us to set up a free consultation, and get started today!