BT

Python 3.5 Brings New Language Features and Library Modules

| by Sergio De Simone Follow 14 Followers on Sep 14, 2015. Estimated reading time: 1 minute |

Recently released Python 3.5 brings a host of changes, including several new syntax features, new library modules, improvements to the standard library, and to security.

Syntax features

Python 3.5 introduces three new syntactic features:

  • coroutines with async-await syntax, which allows developers to write code as if it were sequential. In fact, the compiler will implement it through a sequence of coroutines, thus making it effectively concurrent. In the following example, multiple await statements can be thought of as executing sequentially, but they would not cause any actual block:

    async def read_data(db):
    data = await db.fetch('SELECT ...')
    if (data...)
        await api.send(data ...')
    
  • a matrix multiplication operator that allows to express the multiplication between matrices as a @ b. This will allow to write:

    S = (H @ beta - r).T @ inv(H @ V @ H.T) @ (H @ beta - r)
    
    instead of:
    S = dot((dot(H, beta) - r).T, dot(inv(dot(dot(H, V), H.T)), dot(H, beta) - r))
    	
  • unpacking generalization, which is meant to extend the allowed usage of the * unpacking operator and make it possible to use it multiple times in function calls, or inside of tuples:

    >>> print(*[1], *[2], 3)
    1 2 3
    >>> dict(**{'x': 1}, y=2, **{'z': 3})
    {'x': 1, 'y': 2, 'z': 3}
    
    
    >>> *range(4), 4
    (0, 1, 2, 3, 4)
    

Library Modules

New library modules in Python 3.5 introduce:

  • type hints, which aim to enable type checking annotations to 3rd party modules while also allowing unaltered execution if desired.
  • new zipapp module provides an API and command line tool for creating executable Python Zip Applications.

Other changes brought by Python 3.5 include:

Additionally, SSLv3 has been disabled by default, although it can be enabled if required.

Rate this Article

Adoption Stage
Style

Hello stranger!

You need to Register an InfoQ account or or login to post comments. But there's so much more behind being registered.

Get the most out of the InfoQ experience.

Tell us what you think

Allowed html: a,b,br,blockquote,i,li,pre,u,ul,p

Email me replies to any of my messages in this thread
Community comments

Allowed html: a,b,br,blockquote,i,li,pre,u,ul,p

Email me replies to any of my messages in this thread

Allowed html: a,b,br,blockquote,i,li,pre,u,ul,p

Email me replies to any of my messages in this thread

Discuss

Login to InfoQ to interact with what matters most to you.


Recover your password...

Follow

Follow your favorite topics and editors

Quick overview of most important highlights in the industry and on the site.

Like

More signal, less noise

Build your own feed by choosing topics you want to read about and editors you want to hear from.

Notifications

Stay up-to-date

Set up your notifications and don't miss out on content that matters to you

BT