This week’s release of Python 3.9 “brings forward significant changes to both the features of the language and to how the language is developed,” writes InfoWorld — starting with a new yearly release schedule and performance-boosting parser improvements:
– Python makes it easy to manipulate common data types, and Python 3.9 extends this ease with new features for strings and dictionaries. For strings, there are new methods to remove prefixes and suffixes, operations that have long required a lot of manual work to pull off. [The methods are named .removeprefix() and .removesuffix() and their return value is the modified string]

– For dictionaries, there are now union operators, one to merge two dictionaries into a new dictionary and one to update the contents of one dictionary with another dictionary.
– Decorators let you wrap Python functions to alter their behaviors programmatically. Previously, decorators could only consist of the @ symbol, a name (e.g. func) or a dotted name (func.method) and optionally a single call (func.method(arg1, arg2)). With Python 3.9, decorators can now consist of any valid expression…provided it yields something that can function as a decorator…

– Two new features for type hinting and type annotations made their way into Python 3.9. In one, type hints for the contents of collections — e.g., lists and dictionaries — are now available in Python natively. This means you can for instance describe a list as list[int] — a list of integers — without needing the typing library to do it. The second addition to Python’s typing mechanisms is flexible function and variable annotations. This allows the use of the Annotated type to describe a type using metadata that can be examined ahead of time (with linting tools) or at runtime…
– Python extension modules, written in C, may now use a new loading mechanism that makes them behave more like regular Python modules when imported.

of this story at Slashdot.

…read more

Source:: Slashdot