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 ๐Ÿ‘‡
1
4
17
1,493
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?
1
0
1
1,129
Python is getting quite colourful!
0
0
5
1,306
Replying to @mathsppblog
Explicit lazy imports

x.com/mathsppblog/stโ€ฆ
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.
1
0
0
242
Replying to @mathsppblog
New built-in `sentinel`

x.com/mathsppblog/stโ€ฆ
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 ๐Ÿ‘‡
0
1
1
133
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 ๐Ÿ‘‡
1
0
6
1,074
Replying to @mathsppblog
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 ๐Ÿ‘‡
1
1
1
231
Replying to @mathsppblog
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/sโ€ฆ
0
0
1
186
What's an example usage of a module-level `__getattr__` you've come across?
1
0
0
1,594
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.
1
0
8
1,296
Replying to @mathsppblog
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-โ€ฆ
1
0
0
224
Replying to @mathsppblog
I'm doing 15 days of Python 3.15.

Follow @mathsppblog for the whole journey.

Check my profile for the free email series.
0
0
0
184
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?
2
0
1
1,316
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 ๐Ÿคž
2
0
7
1,404
Rodrigo ๐Ÿ๐Ÿš€ retweeted
1
9
84
3,567
The syntax highlighter on my website isn't keeping up with Python ๐Ÿ˜ฎโ€๐Ÿ’จ
0
1
6
1,130
uv self update; uvx whatsnewt
0
1
6
1,240
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?
0
2
8
1,327
Who else is compulsively running `uv self update` to get 3.15.0 through uv?
@dsmproengineer Yup coming today
3
0
13
2,428
๐Ÿ† Top 5 Python 3.15 features to start using today:

1. Lazy imports

2. New built-in `frozendict`

3. New built-in `sentinel`

4. Unpacking inside comprehensions

5. New sampling profiler Tachyon

What's your top Python 3.15 new feature?
4
2
9
1,973
Replying to @mathsppblog
To learn more about each of these features, you can see examples and explanations here:

mathspp.com/blog/the-5-mosโ€ฆ
0
0
2
334