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


Google Code-in 2017 An Epic Achievement
05/02/2018

The 8th annual Google Code-in contest in which teenage students learn about open source and make practical contributions turned out to be "epic" - with 3555 students from 78 countries completing  [ ... ]



Top 10 - PHP For Web Development
02/02/2018

PHP is one of the most widely used programming languages for web development and if you're a web developer you really can't avoid it. Here is a selection of helpul posts about the language and its fra [ ... ]


More News

 

 
 

 

blog comments powered by Disqus

 
 

   
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.