Why would you migrate to Python 3.5?

Why would you migrate to Python 3.5?

Python 35

Why, indeed? A new version release of any popular programming language is an exciting time for programmers and the software product development  world. The September 2015 Python 3.5 release brought in similar reactions. New features in the Python 3.5 are a mix of popular programming languages and add on to what Python programmers are already working on. The additions ensure less typing, less chances of bugs, security improvements, apart from having brand new features in syntax.

Python Stats

Many Python experts (including those at Cuelogic), still count Python 2.7 as a standard stable version. This doesn’t mean later Python versions haven’t been extensively used in the tech world.As per statistics researched by randalolson.com, the percentage of developers using Python 3 went from 60% to 72% from 2013 to 2014. If you consider stats over the two aforementioned years, while 81% of Python users regularly and predominantly used version 2.7, 43% of the same are using version 3.4 often too. About 12% and 5% used version 3.4 and 3.2 frequently, during the survey time period. A logical conclusion – widespread industry use of a new programming language version takes time, but it does occur, as and when development needs arise.

Why Python 3.5?

Finally, a new version is expected to cut down on bugs, time, while adding to security, library and syntax. As Python tools expert Steve Dower mentions in this link, many changes were the result of suggestions and ideas shared by Python users and fans on Python forums. Here are some important new additions:

Matrix multiplication operator

Formerly limited to numeric libraries like NumPy, matrix multiplication has a binary operator “@” for the matrix multiplication functionality. This allows for shorter, cleaner code writing in matrices. Anything related to engineering, science and mathematics benefit a lot with this inclusion. Python is already extensively and effectively used in applications related to the mentioned fields. This new feature further boosts its reputation. The dedicated @ infix operator is now a source of common syntax for matrix math, leading to more readable & compact code. An impending NumPy maths-and-stats release will facilitate @, enable speedy matrix multiplication.

Coroutines (async and await)

Promoting the more approachable asynchronous programming model, async and await syntax will add more back up to coroutines. As a keyword, async allows the function to act like a coroutine, while await as a keyword can help suspending coroutine execution. Promoting concurrency through writing of sequential code is a prime benefit. That new Python developers easily understand either concept, adds to the differentiation. The async/await function is meant as a solution to run syntax asynchronously, consistent with Python’s followed behavior.

Unpacking

It is now possible to apply unpacking from many positions through function calls. The earlier version had unwanted limitations, not favoring readability.This implies extended use of dictionary and iterable unpacking operator. A sequence of some values and its association to comma separated names unpacks it. Previously allowed only on the left hand side of an assignment, the new feature allows you to do the same on the assignment’s right hand side too. Generalized unpacking allows results with comparatively less typing. 

Type hinting & Zipapp

Python language originator Guido van Rossum is a big advocate of type hinting. Annotating variables through type hinting was a feature everybody was waiting for. The intent is to make Python more compiling to offline analysis. Adding tools and base definitions to type annotations has served this purpose. Also, conventions are put in where annotations are not useful. Another new library module is zipapp, that allows developers to work on executable Python zip applications using an API and exclusive command line tool. Application bundling will be much easier with the new zipapp module. Just place all files, including the __main__.py file into the myapp directory and run the file.

Other features, improvements

  1. Another step towards improving code readability has made it to version 3.5, adding % formatting support to interpolation on bytearrays and bytes. Earlier, the code work required to fill in for this functionality affected readability. That is why % formatting is a sensible inclusion.

  2. You can now disable abbreviated usage of long options in the ArgumentParser class. All you need to do is set allow_abbrev to False.

  3. There are notable changes in the provisional asyncio module,from brand new debugging APIs to a proactor event loop that supports SSL. New queue methods include Queue.task_done() and Queue.join().ensure_future() has replaced the async () function, among other little changes.

Migrating to Python 3.5

There is no set format migrating to the latest version of Python 3.5. As the application code architecture and version demands, changes have to be made in the code. For example, if a new Python version includes use of closed brackets, then the same will have to be implemented in the application. Tools to identify the code changes and then alter and test the functionality of the same, can help developers in making the transition in significantly less time.

To conclude, you can visit this Changelog link to view the complete documentation and list of changes in Python 3.5.