Post
Btw, how cool is this logo by @riecatnor.bsky.social and @georgically.bsky.social? Each day, I'll write about a new feature of 3.15. I'll post a highlight here and I'll write a full blog post at mathspp.com/blog You can also receive the highlights directly in your email 👉 mathspp.com/python-315
Top 5 Python 3.15 new features: bsky.app/profile/math...
🏆 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?
Explicit lazy imports bsky.app/profile/math...
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.
0 reposts0 likes
New built-in `sentinel` bsky.app/profile/did:...
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 👇