Whats new in Python 3.5?
Python 3.5 was released in the 2nd week of September, 2015 and brought a bunch of useful changes with it. In this article, I'll be discussing some of the enhancements to the language that I found extremely useful in the latest release.
Apart from some of the smaller improvements like CPython optimizations, deprecations and resolution to porting issues, following are some of the major enhancements that directly or indirectly affects the Python developer community,
async and await
Now we have the ability to use
async for and
async with inside a co-routine
function declared with
async def. Inside a coroutine function, the new await expression
can be used to suspend coroutine execution until the result is available. Any object
can be awaited, as long as it implements the
await suspends the execution of
read_data coroutine until
and returns the result data.
Python 3.5 provides a new infix operator
@ for matrix multiplication. Matrix
multiplication is a notably common operation in many fields of mathematics,
science, engineering, and the addition of
@ allows writing cleaner code.
PEP 448 extends the allowed uses of
* iterable unpacking operator and
** dictionary unpacking operator. It
is now possible to use an arbitrary number of unpackings designed to work in the
Type hints was perhaps the most talked topic in this year’s PyCon ‘15, after Guide introduced it to the world. And predictably, it increased the anticipation amongst the developer community for all the right reasons.
In the latest release, there is a new addition to the directory iteration function,
os.scandir(), in the standard library. Additionally,
os.walk() is now implemented
using scandir, which makes it 3 to 5 times faster on POSIX systems and 7 to 20
times faster on Windows systems. This is largely achieved by greatly reducing the
number of calls to
os.stat() required to walk a directory tree.
Additionally, scandir returns an iterator, as opposed to returning a list of file names, which improves memory efficiency when iterating over very large directories.
Ofcourse, the entire list of ehancements and improvements is pretty long. Refer the official changelog for the complete list.
Did you enjoy reading this article? I'd love to hear your thoughts. Shoot me an email or send me a tweet if you've got any comments.
‹ Back to Home