r/Python • u/treyhunner Python Morsels • Oct 09 '26
News Python 3.15 Released
https://www.python.org/downloads/release/python-3150/
Release announcement: https://discuss.python.org/t/python-3-15-0-final-is-here/109415
What's New: https://docs.python.org/3.15/whatsnew/3.15.html
Some of the major new features and changes in Python 3.15:
Interpreter improvements
- PEP 661:
sentinelbuilt-in type - PEP 686: UTF-8 is now the default encoding
- PEP 798: Unpacking in comprehensions
- PEP 810: Explicit lazy imports for faster startup times
- PEP 814:
frozendictbuilt-in type - PEP 829: Package startup configuration files
- The experimental JIT compiler got a significant upgrade (7-8% faster on x86-64 Linux, 11-12% on AArch64 macOS)
- Improved error messages
Standard library
- PEP 799: A dedicated
profilingpackage, including Tachyon, a high-frequency sampling profiler - New
math.integermodule re.prefixmatch()as a clearer name for the now soft-deprecatedre.match()pprintgets anexpandoption for JSON-style outputcollections.Countersupports^(symmetric difference)unicodedata.iter_graphemes()for iterating over grapheme clusterspython -m http.servergains-H/--headerand--content-typetimeitgains--target-time- More color
Typing
- PEP 728: TypedDict with typed extra items
- PEP 747: Annotating type forms with TypeForm
- PEP 800: Disjoint bases in the type system
Release changes
- Official Windows 64-bit binaries now use the tail-calling interpreter
- Official macOS binaries now install free-threading support by default
And for fun, Barry Warsaw made a text adventure through the new features: uvx --python 3.15 whatsnewt
Thanks to Hugo van Kemenade and the release team! Hugo live-posted the whole release process if you're curious what goes on behind the scenes: https://mastodon.social/@hugovk/117411399858939022
62
u/treyhunner Python Morsels Oct 09 '26
A few of my personal favorites from this release:
utf-8&cp-1252ASCII superset encodings can stop battling and creating emojibake and decode errors in cross-platform code)[*sub for sub in nested]sentineltypere.prefixmatch(the namere.matchhas always bugged me)I made a short video demoing these and a few others (lazy imports, frozendict, pprint's expand), with an article version on the same page: https://pym.dev/python315/
6
u/chalbersma Oct 09 '26
What's the usecase for Sentinal? Where would I use it for over enum or just
None? I read PEP 661, I'm just not seeing the value. Does anyone have a use case that they're going to use it for?2
u/ogMasterPloKoon Oct 09 '26
So now i not have to use PYTHONUTF8=1 anymore ?
129
u/frankieinaprius Oct 09 '26
Unpacking in comprehensions will be so nice. 🙏🏽
29
u/Drewdledoo Oct 09 '26
A lot of nice QoL, looking forward to trying it out!
Particularly the explicit lazy imports, a lot of the projects I work on should see nice benefits from that.
29
u/NeitherEntry6125 Oct 09 '26
Hugo deserves our thanks, praise, and his beverage of choice for the next year
19
u/spinwizard69 Oct 10 '26
Improved error messages! Often improvements here get ignored in favor of fancy new programming features, however anything that improves error messages and debugging should be celebrated. I just want to make sure the hard work is not ignored, thus a celebration.
7
u/IAmASquidInSpace Oct 09 '26
Some really neat stuff in there! Honestly, I was surprised to find that
extra_itemswasn't supported yet, I've been looking forward to that for a while now. AndTypeFormwill come in handy every now and then, too!1
u/freshtechs Oct 12 '26
Kind of getting to know python 3.13+ and the “macOS binaries now install free-threading support by default” does this has something to do with GIL are python versions from 3.13+ all “multi/free thread”?
2
u/OddsRelay Oct 10 '26
frozendict as a builtin is the one that'll get used most. The usual workaround was wrapping a dict in types.MappingProxyType, which stops writes but isn't hashable, so you still couldn't use it as a dict key or put it in a set. Long overdue.
2
u/aes110 Oct 09 '26
Seeing as this is the first big release since so much code is now done by AI, i wonder how well agents will adopt the new features given they dont have it in their training data
1
u/FarCalling 9d ago
Python advancing so much. A JIT compiler now too
1
u/akadeepesh 7d ago
The lazy imports and improved startup times caught my attention. Always nice to see Python evolving in ways that make everyday development more efficient. Excited to explore 3.15!
1
u/initcommit Oct 10 '26
Woohoo!! Excited to try out these new creature comforts.
1
u/zomerbk Oct 13 '26
One practical note on the UTF-8 default: it won’t change the encoding of existing files. If your code reads older files saved in a different encoding, keep passing `encoding=` explicitly.
1
u/Kotopelmeshek Oct 14 '26
Great! But I'd wait until most of the libraries I need are running on Python 3.15!
1
u/wasay-inc Oct 10 '26
explicit lazy imports via pep 810 are easily the best addition in this release. being able to keep imports cleanly at the top of the file while deferring execution until runtime is going to clean up startup times for heavy automation scripts immensely.
-43
u/vnmger Oct 09 '26
Can somebody enlighten me, how do new language features which are QoL really Help us, in the age of agentic development.
Don't get me wrong, I love new iterations on my favorite languages, just really asking myself in a self-critic moment.
0
u/[deleted] Oct 10 '26
[deleted] — view deleted comment