📜 ⬆️ ⬇️

Release Python 3.6 - yes, now it’s with us



It's been 15 months, and finally the world saw the release of the Python 3.6 programming language. There is a lot of new stuff, because it's not for nothing that the developers have been waiting for 15 months. In the release, new modules were added, standard libraries were updated, sets of various settings were improved. In general, Python 3.6 has received many improvements, which can be considered an excellent gift for the New Year. Let's take a closer look at what Santa Claus brought us a new release.

In particular, there is support for formatted string literals , so you can define a string that contains substitutions. Expressions in braces are calculated by substituting in the text of the string during program execution, and are also formatted using the format () protocol. As an example, the developers give this fragment:

>>> name = "Fred" >>> f"He said his name is {name}." 'He said his name is Fred.' >>> width = 10 >>> precision = 4 >>> value = decimal.Decimal("12.34567") >>> f"result: {value:{width}.{precision}}" # nested fields 'result: 12.35' 

The readability of numbers can be improved by using underscores, for example, in this way - 1_000_000 or 0x_FF_FF_FF;
')
A new module, secrets , has now been added to the standard library, which provides the means to generate cryptographically reliable pseudo-random numbers that are suitable for generating various keys and tokens;

In the modules hashlib and ssl added support for OpenSSL 1.1.0 .

The new version defines the syntax of annotations for variables , which makes it possible to transfer information about the types of variables to the interpreter. The __annotations__ attribute of the class or module now contains annotations, although there are no restrictions here, this feature is used to structure metadata that can be used by third-party tools and libraries. Example:

 primes: List[int] = [] captain: str # Note: no initial value! class Starship: stats: Dict[str, int] = {} 

In the hashlib module , developers added support for the BLAKE2, SHA-3, and SHAKE hashing algorithms, and the scrypt () key generation function is also implemented;

Added ability to define asynchronous generators . So, in Python 3.5, it was impossible to use await and yield simultaneously in the body of a single function. Here, in the new release of this restriction is no longer. Thus, it is possible to determine the generators that operate in asynchronous mode:

  async def ticker(delay, to): """Yield numbers from 0 to *to* every *delay* seconds.""" for i in range(to): yield i await asyncio.sleep(delay) 

Added quite a lot of improvements that are associated with work on Windows;

Also added is the possibility of asynchronous processing of so-called comprehensions ( list inclusions ) by working with the expression “async for” for such elements as lists, sets and dictionaries. There is also the possibility of using await expressions for almost all types of list inclusion:

  result = [i async for i in aiter() if i % 2] result = [await fun() for fun in funcs if await condition()] 

The typing module is now ranked stable;

The tracemalloc module has undergone processing; the tools for diagnosing errors in memory allocation have been greatly expanded;

Of course, there are much more updates, information about all new and updated moments can be obtained here .



Colleagues, we, Kingservers company, are now looking for IT authors for technical sites (not Habrahabr and not Geektimes, third-party Russian-language and English-language resources). A condition - a person who writes an article (it must be literate and technical) must also have the opportunity to publish it on such a resource. If you are such an author, write in a personal.

Source: https://habr.com/ru/post/318354/


All Articles