Pinned Tweet
Python 3.15.0 was just released!
To celebrate, I'm doing 15 days of Python 3.15.
Each week day, I'll write about a new Python 3.15 feature.
We'll cover lazy imports, the new built-ins, the DX improvements, some new stdlib niceties, and MUCH more.
I'll collect my posts here 👇
I can't remember Python before this.
Before Python underlined the part of the line that raised the error.
Who remembers what Python version this was added on?
Explicit lazy imports
nitter.cf/mathsppblog/status/211…
New built-in `sentinel`
nitter.cf/mathsppblog/status/211…
What do you do when you can't use `None` as the default?
You can use `object()`...
Or a singleton class...
Or another workaround...
And all these hacks had flaws.
That's why Python 3.15 introduced the built-in `sentinel`.
You can use it to create placeholder values 👇
There are many benefits to using `sentinel`.
One of them is that typing sentinels is much cleaner than typing any of the alternatives.
That's because sentinels can be used as their own type.
Just like `None` can 👇
If you want to learn more about how to create and use placeholder values in 3.15, read the article below
mathspp.com/blog/pydonts/sen…
Python startup times just got faster.
In 3.15, you can use the keyword `lazy` to make a lazy import (`math` and `Path` below).
Lazily imported modules are only loaded
WHEN they're used, and
IF they're used.
Use them to defer loading of modules that may not be required.
If you want to learn more about explicit lazy imports.
See use case scenarios.
Learn how to make them backwards compatible.
Etc.
Read this blog post:
mathspp.com/blog/explicit-la…
I'm doing 15 days of Python 3.15.
Follow @mathsppblog for the whole journey.
Check my profile for the free email series.
What's the consensus on `sentinel` vs `None`?
Assume no backwards compatibility concerns.
Do you still use `None` for pretty much all “nothing” usages and use `sentinel` only when `None` doesn't cut it?
Or are you going to default to `sentinel` for placeholders?
Who had this ridiculous idea of doing 15 blog articles about Python 3.15 in 15 days while also running 5 workshops in 10 days?
My weekly Monday newsletter is delayed and will only be coming out tomorrow 🤞
uv 0.13.0 is out now and it uses Python 3.15 as the default stable version!
Time to go update my uv cheatsheet to note that it's compatible with uv 0.13.0
Given the recent wave of supply chain attacks, should I include --exclude-newer in the cheatsheet?














