Search anything:

New Features in Python 3.8

Binary Tree book by OpenGenus

Open-Source Internship opportunity by OpenGenus for programmers. Apply now.

Reading time: 30 minutes | Coding time: 5 minutes

In this post, we have discussed several features of Python 3.8 which will allow budding programmers and experience Pythonistas to get acquainted with these new features. The new features in Python 3.8 are:

  • Walrus Operator
  • Positional Only Operators
  • '=' is now supported by fstrings
  • Pickling Protocol
  • Reversible Dictionaries

Python is a general purpose programming language that has been widely used in various applications across Computer Science studies which includes Artificial Intelligence, Machine Learning, Web Development, Cross-Platform Application Development and more. Its expressible syntax which is more readable and understandable makes it an ideal choice for budding programmers to start with. With a large and broad library and modules support, Python is one of the most popular languages on Earth.

Python 3.8 is the newest release of the Python Programming Language and is expected to make strides in Python Development Community ever since Python 2.7 will go out of official maintenance past 2020. Released on October 14, 2019 Python 3.8 adds some new features to this whole lot extensible programming language which is expected to further enhance the operatibility and enhancibility of this new language.

Let us explore the new features in Python 3.8:

1. Walrus Operator

The most striking change of Python 3.8 is the Walrus Operator which is a step ahead of the traditional assignment operator and is written as := and the associated code for the operator is:

if(a:=get_input()) is not None:

Walrus Operator assigns values to the variables which can be a part of the expression without needing for the programmer to initialize the variables beforehand. The primary advantage of this operator would be to save the user from writing a few lines of code and also to save the value of an expression in a condition.

It is also expected to improve the readibility of the code though at the expense of clarity of the code. Currently it is available for List Comprehensions and Statement Forms.

2. Positional Only Operators

Thanks to the Positional Only Operators, a Special Marker / can now be used for defining the function arguement list that was earlier possible only with ==== marker. The addition of Positional Only Operators allow for more robust Application Programming Interface (API) designs that further augments the processing capabilities of the language.

The associated code for Positional Only Operators are:

def sum(a,b,c=None,/):
   if c is not None:
   return d  

This means that the passing values for a, b and c are being done positionally and not using the traditional keyword arguements. The primary advantage of this operator is for developers who design APIs. For APIs, thanks to this operator, we can make our API parameter name backward compatible and make the operators map to arguements based on their position in the arguement list.

3. '=' is now supported by fstrings

Python 3.8 now adds '=' to the fstrings which further enhances the print style debugging. With '=' now supported by fstring we can enhance the code in the following way:


The output of the following code would be 10.

Now rewriting the same code with '=', we can write:


The output of the following code would be x*10=100

4. Pickling Protocol

Pickling Protocol earlier allowed developers to serialize data and code which can be used in cross-platform applications which made the language quite versatile. It allowed us to save Data Structures like Dictionary into a file which can be reloaded later. With Python 3.8, the Version 5 of Pickle Protocol was released which enabled pickling of a wider variety of Python Objects like Numpy Arrays, memory-views and byte memory. The new Pickle Protocol also allows to cut down the number of memory copies that has to be made for each object.

5. Reversible Dictionaries

With Python 3.8, reversed() function is now officially supported on Dictionaries. Earlier in Python 3.7, the order of keys in dictionaries were preserved but with Python 3.8 we can now access dictionary elements in the reverse order of insertion. The code for the operation is:

>>> X=dict(a=5,b=10)
>>> print(list(reverse(X))
>>> print(list(reverse(X.items()))

In addition to all these new features, further new features that were added are SyntaxWarnings which are thrown when a comma is missing from Tuple. Further new measures were added to enhance the performance and speed of the code, which fixes the earlier issues that plagued the performance issues. Python 3.8 also fixes the C API that was used in CPython, which is Python Implementation on the popular C Programming Language, which allows developers to use C engine in Python as well.

With these new features, Python 3.8 is expected to take a new lead with a steady focus on improving the speed, stability and performance of this new language. According to Github's annual state of the Octoverse which reports about the popular programming languages, Python is at the second spot which is a jump from its last year position at third. Displacing Java at second spot, Python has earned a mark as one of the fastest growning languages with a support of large community and ecosystem backing it up.

New Features in Python 3.8
Share this