What's new in Python 3.8

As common with all areas of the tech world to improve on things previously made when the knowledge pool grows, Python is no exception. Since its existence, Python has undergone various upgrades, culminating in the release of various versions each with improved features to meet the developer’s demand. This has helped create a great, efficient and effective platform for successful programming experience. One of the news that the world of programming was glad to receive in December 2019 was the announcement of the release of Python is 3.8.1 which came with its distinct amazing features.

The 3.8 series is the latest release in the Python version upgrade series, and it comes with new features and optimizations. So far two versions of the 3.8 series have been released. The first of the 3.8 series (3.8.0) was released on the 14th of October 2019 while the second, 3.8.1 was released on the 18th of December 2019. According to Python, it is the first maintenance release of the 3.8 series. Python 3.8 brings with it a lot of amazing features that quite differentiate it from the 3.7 series. But this is not just about differentiation. It’s about an improved developer experience and better service to the user. Here we take a look at the improved and upgraded experience Python 3.8 has to offer. Our focus here actually is the 3.8.1, because it is the latest in the series, and as it is part of the 3.8 series, you can be sure we are on track for it.

 Here we go!

New Python 3.8 features

Assignment expressions (The Walrus Operator)

In the 3.8 version of python, we have a new kind of assignment expression, and it is known as the Walrus Operator. ( := ). It enables the developer to assign values to a variable as part of an expression. It can set and return a variable in one line. This is a major achievement in the area of brevity. It saves the developer some lines of code when the value of an expression is about to be said or used in subsequent conditions.

Positional-only arguments

This is another feature that sets the 3.8 series apart from the 3.7. A special marker ‘/’ can now be used when defining a method’s arguments, to specify that the function only accepts positional arguments on the left of the marker. With this, the Python language’s consistency for robust API design is improved.

A New Syntax Warning

In the new version, there’s a new warning for missing comma along with the error message. A helpful warning message will be thrown up by the interpreter in this situation. The warning points out you probably miss a comma. This goes a long way to help the user in the fast detection of their error. With the way it is designed, it offers great help in debugging and avoiding bugs.

Dictionary with reverse

There is a start to the preserving order of keys started in 3.7 by Python as reversed() now works with the dictionary. However, the extra pick in 3.8 is that you can also now reverse it.

 f-strings now support “=”

Now the “=” operator within f-string can be used to get and print value. What this means is that arithmetic operations can now be performed within f-string.

>>> site_name = 'be a python dev'
>>> created_at = date(2019, 6, 01)
>>> f'{site_name=} {created_at=}'
"site_name='be a python dev' create_at=datetime.date(2019, 6, 01)"

There’s a new protocol for creating pickle files

In Python, pickle’s use is for de-serializing and serializing data that can also be used somewhere else. By default, Python will be using protocol 4 in the 3.8 series version, and protocol 5 can also be used with it, thereby resulting in APIs to take full advantage and hence creating improved performance. This will work well with Flask and Django, even in servers with limited or low space. It’s very great news for those working in the data science field.

Multiprocessing shared memory

Python supports V style shared memory block in Python 3.8. This gives allowance for the creation of memory segments that can be shared between Python processes. Data could be shared by sending it over a network, writing it out to a file or serializing it using Python’s pickle module in previous Python versions. But with shared memory, provision has now been made for a faster path for passing data between processes.  This allows for more efficient use of processors and processor cores by Python.

CPython Improvement

Those in the field of data science have encountered instances where the Jupyter or Pyhton environment crashed because of a huge amount of data.  But now that Python has made it known that Python’s C engine has been improved, optimizations will be made easy. Now, there is an expectation of better results in processing and querying data.

Improvement in Performance

The 3.8 release has added some performances that speed up the interpreter. Here are some of them

  • operator.itemgetter() now have a 33% speed increase. It was made possible by the optimizing of argument handling and adding a fast path for the common case of a single non-negative integer index into a tuple, the basic typical use case in the standard library.
  • collections.namedtuple() are now the fastest form of instance variable look-up in Python, with a 2% speed increase.
  • If the input has a known length, the list constructor does not over-allocate the internal item buffer, thereby making the created list 12% smaller on average.
  • Uuid.UUID now uses slots to scale back its memory footprint.
  • Now class variable writes are twice as fast.
  • Invocation of some simple built-ins and methods is now with an increased speed of 20-50%.

With all seen so far, the features in the newly released python 3.8 version series make it worth upgrading to. It will be a developer’s most advantageous move for an optimum developing experience. An improved level of performance is something people in various fields look forward to with keen interest. The Python developer is no exception. Being outdated isn’t a game the developer should be given to.  Get Python 3.8.1 now and enjoy the goodies.

Thank you for visiting!

Please remember if you found this content useful and would like to see more python and software development articles from us, help us conquer the google algorithm in any of the ways below:

If you didn’t find what you expected feel free to use the contact page and let us know ways we can improve or what would help you grow as a developer better! I am honored by every view and it takes a village to really make this great.


Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s