BT

Python 3.5 Promises New Syntax Features

| by James Chesters Follow 1 Followers on Jul 14, 2015. Estimated reading time: 2 minutes |

The Python Software Foundation has announced new features expected in Python 3.5.

In the article What’s New In Python 3.5 core developer Benjamin Petersen details new syntax features, and new library modules, as well as new built-in features and significantly improved library features.

Among the dynamic language's new syntax features is coroutines with async and await syntax. The feature's author, Yury Selivanov, says "Feedback on the initial beta release of Python 3.5 resulted in a redesign of the object model supporting this PEP to more clearly separate native coroutines from generators -- rather than being a new kind of generator, native coroutines are now their own completely distinct type."

Selivanov says he wants to make "coroutines a native Python language feature", clearly separating them from generators. Selivanov says this would remove "generator/coroutine ambiguity", and make it possible "to reliably define coroutines without reliance on a specific library."

According to Selivanov, "native coroutines and the associated new syntax features make it possible to define context manager and iteration protocols in asynchronous terms." Making it possible for Python programs to perform asynchronous calls when entering and exiting a runtime context, to perform asynchronous calls in iterators.

New with the 3.5 release is the zipapp module, providing an API and command line tool for creating executable Python Zip Applications. Previously introduced in Python 2.6, Petersen notes that Zip Applications were not well publicised. Daniel Holth and Paul Moore, authors of the module, say they aim to re-publicise the feature, as well as defining the .pyz and .pyzw extensions as "Python ZIP Applications" and "Windowed Python ZIP Applications", and provide simple tooling to manage the format.

Holth and Moore say the new module will provide functions including create_archive(source, target=None, interpreter=None, main=None) and get_interpreter(archive).

Among the improved library features comes collections.OrderedDict now implemented in C, improving its performance between 4x and 100x times, Petersen notes.

Furthermore, developers are now able to pass bytes to the tempfile module’s APIs, which will return the temporary pathname as bytes instead of str. Petersen says

[this] will return the temporary pathname as bytes instead of str. It also accepts a value of None on parameters where only str was accepted in the past to do the right thing based on the types of the other inputs. Two functions, gettempdirb() and gettempprefixb(), have been added to go along with this. This behavior matches that of the os APIs.

The Python community's response so far to the features has been warm. In the Reddit discussion What's New in Python 3.5 user beaverteeth92 commented "I'm so ready for that matrix multiplication operator. It's going to make my code so much more legible", with similar messages of support coming from nillion42, who said "I use matrix multiplication for various simulation and engineering related work. Python+numpy can often be used as a matlab alternative. In addition, I write code involving coordinate transforms using matrices at home."

The Python Software Foundation encourages everyone to contribute to Python, and includes details on how to get involved in their Python Developer Guide.

Python is developed under an OSI-approved open source license, making it freely usable and distributable, even for commercial use. Python's license is administered by the Python Software Foundation.

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