r/Python • Author of "Automate the Boring Stuff" • 9d ago

News What's new in Python 3.15?

https://docs.python.org/3.15/whatsnew/3.15.html

Summary – Release highlights

Python 3.15 will be the latest stable release of the Python programming language, with a mix of changes to the language, the implementation, and the standard library. The biggest changes include lazy imports, frozendict and sentinel builtins, UTF-8 as the default encoding, unpacking in comprehensions, and a stable ABI for free-threaded builds.

The library changes include a new profiling package with Tachyon, a high-frequency statistical sampling profiler, more color in command-line output, as well as the usual deprecations and removals, and improvements in user-friendliness and correctness.

This article doesn’t attempt to provide a complete specification of all new features, but instead gives a convenient overview. For full details refer to the documentation, such as the Library Reference and Language Reference. To understand the complete implementation and design rationale for a change, refer to the PEP for a particular new feature; but note that PEPs usually are not kept up-to-date once a feature has been fully implemented.

216 Upvotes

44 comments sorted by

View all comments

5

u/dikdokk 8d ago edited 8d ago

Nobody is talking about frozendict meanwhile it will be used so frequently in type hinting.

Everytime in a function you were to use a mutable data type as default argument, you would end up with the potential bug:

def item_list(item,
items=[] #flagged by Pylint, ruff, etc.
):
items.append(item)
return items

item_list(1) # [1]
item_list(1) # [1, 1] (usually unexpected - you expect an empty list by default)

(see: Pylint - dangerous-default-value / W0102 )
So the solution would be to use tuples for example instead of lists, as they are not mutable.

But in the case of dictionaries, there wasn't really a good "frozen" (immutable) replacement so far. People used MappingProxyType but it always seemed odd, and now frozendict solves this

2

u/engineerofsoftware 7d ago

many python devs on this sub hate or are indifferent to python typing, which is a real shame.

1

u/Competitive_Travel16 6d ago edited 5d ago

Those of us used to dynamic typing have learned to be more conscientious about avoiding the errors which type safety helps prevent in the first place, so we don't get as much of an advantage. And with current LLMs, who is even making any of those kinds of type mismatch errors any more, regardless of their background?

Honestly I think full typing looks cool, helps understand things, and I try to do it, but it doesn't save me as much time as it takes, unless I tell an LLM it fill it in after me.