#047 - Python 3.13: What’s New and What’s Relevant for Engineers?
A nice update with a few quality of life improvements.
Hello engineers of earth and beyond 👋.
Python 3.13 is officially here, and while it doesn’t bring sweeping changes to the language, it introduces several useful updates that can benefit engineers. From improvements in error reporting to under-the-hood tweaks in performance, there are a few new features that might just make your workflow a little more efficient.
If you want to fall asleep in a swift manner, you can check out the detailed Python 3.13 release notes here: https://docs.python.org/3/whatsnew/3.13.html
This article is a breakdown of the key updates that matter most for engineers.
1. Better Error Messages and Interactive Interpreter
Python 3.13 introduces an improved interactive interpreter, with clearer error messages and color-coded tracebacks, pretty nice!
For instance, let’s say you’re writing a script and you accidentally omit a closing parenthesis or forget to define a variable.
In Python 3.12, you get a generic syntax error, but Python 3.13 will point directly to the issue with color highlighting, making it easier to spot and correct. Additionally, it offers suggestions—if you misspell a function, Python will try to infer what you meant, making debugging a smoother process.
These improvements may seem small, but when dealing with complex projects every bit of clarity helps.
I won’t notice this as much because I’m usually working within a jupyter notebook but I am definitely a fan of colour coded debugging.
2. A Leaner Standard Library
One of Python’s long-standing principles is the “batteries-included” philosophy, meaning the standard library comes with a lot of built-in functionality. However, Python 3.13 has removed 19 outdated or redundant modules—what are often referred to as “dead batteries.” This means a slightly leaner environment, with less bloat.
Modules like chunk, crypt, and telnetlib are no longer part of the core library.
https://docs.python.org/3/whatsnew/3.13.html#whatsnew313-pep594
I never even heard of these, let alone used them so I won’t lament these losses.
3. Math Updates
A more technical but interesting update is the addition of the FMA (Fused Multiply-Add) operation in the math
module. This function performs the calculation of x * y + z
in a single step, avoiding any intermediate rounding errors. For engineers working with floating-point arithmetic in design calculations (which is all of us), the reduction of precision errors could be useful.
Float precision errors are a common sticking point for Python haters. I have never encountered any problems with them but there are certainly cases where larger models can results in undesirable rounding errors that can stack up over iterations or subsequent calculations.
For example, if you have an expression with 30 terms like r = x1*y1 + x2*y2 + ... + x31*y31
, without FMA, each multiplication and addition would introduce a very small rounding error after every step.
With FMA, each xi*yi + zi
is computed with just one rounding, reducing the overall number of rounding errors across all 30 terms. This means the final result will be more accurate because fewer rounding steps lead to less cumulative error.
Again, your mileage may vary on this one.
4. Typing Updates: More Robust and Read-Only Dictionaries
If your workflow involves data validation and management (e.g., unit pricing databases or design parameter dictionaries), maintaining data integrity is important. Python 3.13 adds a read-only construct to the typing
module, allowing engineers to define parts of a dictionary as immutable.
For example, if you want to ensure that a material cost dictionary remains unchanged once it’s set, you can mark it as read-only to prevent accidental modifications:
from typing import TypedDict, Final
class MaterialCost(TypedDict):
name: str
price: Final[float] # This value cannot be changed
# Create a material dictionary
concrete = MaterialCost(name="Concrete", price=293.00)
# Later in the program, trying to change the price will trigger a type error
# concrete['price'] = 300.00 # This will raise an error
For engineers managing large databases of material properties or costs, this feature helps lock down critical data, ensuring your calculations remain consistent and accurate.
Not a huge issue but as project teams become more inclined to collaborate on code based projects, it’s nice to maintain control over certain non-negotiable variables!
I must insist that my gravitational constant is 9.80665 m/s2.
Update 💡
I have been notified by the eagle eyed Peter Debney, that the gravitational constant above is not a constant and varies with location on the planet. He’s even gone as far as to provide a reference map of the UK’s gravitational range (below). Peter discovered this while investigating space elevators. At sea level, ‘g’ typically ranges from about 9.766 m/s² at the equator to about 9.866 m/s² at the poles, which results in approximately a 1% difference.
Thank you Peter!
5. Path Handling: Simplified File URIs
For those managing automated data logging or file handling, Python 3.13 simplifies the process of working with file URIs by allowing you to create path objects directly from these URIs. This is useful when dealing with data across multiple systems, such as sensor data from field installations or cost data stored on remote servers or cloud storage.
In previous Python versions, converting a file URI to a file path required manually parsing the URI and handling the path formatting. Python 3.13 eliminates this complexity with the new `Path.from_uri()` method, which handles the conversion for you.
from pathlib import Path
# Automatically create a path object from a file URI
path = Path.from_uri("file:///path/to/your/data.csv")
This update makes it easier to manage files in cross-platform or networked environments without the need for manual conversion steps. A small but nice addition.
6. Improved Garbage Collection
Python’s garbage collection has been updated in 3.13 to reduce pause times when working with large datasets or complex data structures. This won’t impact everyone, but if you’re dealing with memory-intensive tasks—like large-scale simulations, CFD sim, or repeated file I/O—this update could lead to more efficient execution.
For most people working with small- to medium-sized datasets, this change won't be immediately noticeable. However, once you’re handling larger, memory-intensive workloads—such as simulations or sensor data processing—the incremental garbage collection can smooth out performance.
Data sets will continue to become larger and higher fidelity so eventually I think we will find this useful!
7. Experimental: Free-Threaded Python and the GIL
Python 3.13 introduces an experimental feature that removes the Global Interpreter Lock (GIL), allowing Python programs to run threads in true parallel on multi-core processors. This can significantly boost performance for multi-threaded applications like simulations or computations that need parallel execution. However, this feature is experimental and must be explicitly enabled, so it’s not ready for general use just yet. For most single-threaded programs, this change won’t make a difference.
I’m using Polars for my heavier lifting in terms of data management but maybe there are applications in some of the numerical energy models I am working with. I will report back on this feature in the future.
Conclusion: What’s Most Relevant for Engineers?
For most engineers, the Python 3.13 improvements that stand out are the improved error handling and the nice colour coded interactive interpreter. These features make Python more intuitive and accurate for typical engineering tasks.
There are many more changes but none of them jumped out at me as truly significant for my use cases.
Other more complex changes, like free-threaded execution are significant in the broader Python ecosystem but are less relevant for general data science and engineering tasks. If your workflow involves basic analysis, scripting, or small-scale automation, these larger changes will not affect your day-to-day work significantly.
In short, Python 3.13 brings incremental improvements that will help but the more experimental features can be safely ignored for now unless you’re working on performance-critical applications or want to drive yourself insane.
Good luck out there everybody.
See you in the next one.
James 🌊