Python 3.7 Adds Data Handling Classes
Written by Kay Ewbank   
Friday, 09 February 2018

The first of four beta previews of Python 3.7 is now available, with a new DataClasses module, an easier way to enter the debugger, and a UTF-8 mode that uses UTF-8 encoding by default.

The scheduled date for the general release of Python 3.7 is June 2018, and this beta is feature complete for that final version.

The first change to Python is the addition of the dataclasses module. This is designed to provide an alternative to the way Python developers had, until now, to use boilerplate code to instantiate classes with a lot of initializers. The new module provides a class decorator that inspects the class’s variable annotations, and based on what is present, adds methods including init, repre and eq to the lass. It is similar to typing.NamedTuple, but also works on classes with mutable instances, among other features.

pythonbanner

Another improvement in the 3.7 is a new C API for thread-local storage in CPython. There was already a C API for thread-local storage support; but the existing Thread Local Storage (TLS) API has used int to represent TLS keys across all platforms. This worked fine on officially-support platforms, but meant the code wasn't particularly portable.The new thread specific storage (TSS) uses a new type Py_tss_t instead of int to represent TSS keys. This is an opaque type, and its definition can be made specific to the underlying TLS implementation, so that it will be possible to build CPython on platforms where the native TLS key is defined in a way that cannot be safely cast to int.

There's also a new development mode command line option and Pythondevmode environment variable to enable CPython’s “development mode”. This introduces additional runtime checks that are too expensive to be enabled by default. The options that are activated by using the -x dev mode include a debug mode for the asynchronous operations module that offers more detailed logging and exception handling for asynchronous operations; and debug hooks for memory allocators. 

Another improvement is a new UTF-8 mode that makes Python ignore the locale and use UTF-8 encoding. Python has supported UTF-8 handling of strings for many years, but if the locale is sett to ASCII, this would until now override the UTF-8.

There are a number of other improvements and some performance improvements including faster method calls, more efficient optimization of source code constants, and faster matching in regular expressions where the match is case insensitive.

 

pythonlogo

 

 

More Information

What's New In Python 3.7

Related Articles

IPython 6 Released

Python 3.6.0 Beta 1

SciPy1.0 Released

Python 3.5 In Preview

 

To be informed about new articles on I Programmer, sign up for our weekly newsletter, subscribe to the RSS feed and follow us on Twitter, Facebook or Linkedin.

 

Banner


Rust And C++ Should Be Friends?
20/11/2024

The Rust Foundation has just released a statement on Rust and C++ interoperability and Google is ponying up $1 to see that it gets done.



Go At Highest Rank Ever in TIOBE Index
20/11/2024

Go is currently in 7th place in the TIOBE Index for November 2024. Not only is this is the highest position it has ever had, it's percentage rating is almost equal to its all-time-high. Will Go contin [ ... ]


More News

 

espbook

 

Comments




or email your comment to: comments@i-programmer.info