Python 3.7 Adds Data Handling Classes
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, FacebookGoogle+ or Linkedin.

 

Banner


What Can Devs Expect at Google I/O and Microsoft Build?
12/04/2018

Two of the big annual developer conferences are taking place in the second week of May and now we have quite a lot of information of what is on the agenda for both of them.



What Attracts Devs To Open Source
02/04/2018

In an era in which we are becoming more an more reliant on open source software, it is important to know how to  recruit and retain core developers - the ones that are key to a project's survival [ ... ]


More News

 

 
 



Comments




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

 
 

   
Banner
RSS feed of news items only
I Programmer News
Copyright © 2018 i-programmer.info. All Rights Reserved.
Joomla! is Free Software released under the GNU/GPL License.