What's new in Python 3.5

Introduction

According to the development roadmap (PEP-478), Python 3.5 is scheduled for official release on 9/13 (probably US time). .. An additional release candidate (rc4) may have been [released] on 9/9 (https://www.python.org/downloads/release/python-350rc4/), which may be a bit late, but probably It will come out within a week. So, I made a Japanese summary of the changes in Python 3.5 + a comment. The original story is "Summary --Release Highlights" at the beginning of here.

To try Python3.5, download the latest release candidates from here. Or if you are using pyenv, you can easily install it with pyenv install, but the latest version of pyenv v20150901 only supports up to rc2, so you have to put up with it or fetch pyenv from HEAD. If you are using homebrew, it looks like this.

brew uninstall pyenv #If already installed
brew install pyenv --HEAD
pyenv install 3.5.0rc4
2015/09/14 postscript

As planned, 3.5.0 has been released. To be honest, I didn't expect to come so soon ..

pyenv was also updated immediately to 20150913, with 3.5.0 officially supported. It's already on Homebrew. Everyone works fast! So, if you want to try it, this is all right.

brew install pyenv #Or if you have installed it, brew upgrade
pyenv install 3.5.0

Python 3.5 release highlights

New syntax features

Matrix multiplication operator

PEP-465 Proposed specification addition that allows matrix multiplication to be written in the form of ʻa @ b` .. The strange thing is that the standard library doesn't provide an implementation that uses it, just the spec. Instead, some external libraries, such as numpy, have announced support.

Corroutine with async and await

Added specifications for defining and using corroutines proposed in PEP-492. Until now, it was possible to create a corroutine using Generator, but in order to make it easier to understand, the keywords async and await were introduced and the specifications were expanded.

Further generalization of unpacking

An extension of value expansion using * and ** as proposed in PEP-448. It can be used multiple times as a function argument, such as print (* [1], * [2], 3), or it can be used in tuples, lists, and dictionaries, such as [* range (4), 4]. Will be.

New library modules

zipapp

Python has the ability to execute zipped python code. Moreover, since v2.6![PEP-441](https://www.python. The tool that was made in org / dev / peps / pep-0441 /) is zipapp. The Python code that has been zipped is called "Python Zip Application", and the functions for creating it are provided.

New built-in features

Formatting by% in Bytes and Bytearray

So far, I could do something like "% 04x "% 10, but the result is str type. An extension that allows it to be a bytes type in the form of b"% 04x "% 10.

Hex method support for Bytes, Bytearray, Memoryview

You will be able to do things like b'\ xf0 \ x9f \ x90 \ x8d'.hex ().

tuple indexing in memory view

It seems that tuples will be able to index to access the elements of a multidimensional array (matrix).

Added gi_yieldfrom attribute of Generator

I didn't really understand the need for this ...

New exception RecursionError

A type of RuntimeError that occurs when the maximum number of recursion is exceeded.

New exception StopAsyncIteration

Exception raised at the end of a repeat with asynchronous Iterable created by async for.

CPython implementation

Error handler change for sys.stdin / sys.stdout

When LC_TYPE is POSIX locale (C locale), sys.stdin and sys.stdout will now use the surrogate escape error handler instead of the strict error handler.

Abolition of .pyo

When I ran Python with the -O or -OO option, the optimized byte compilation results were stored in .pyo files instead of .pyc. From Python 3.5 we will deprecate it and store it in a .pyc file, with the optimization level in the filename (eg xxx.cpython-35.opt-1.pyc) (PEP-488)

Multi-phase initialization of extension

Until now, built-in modules and extensions have been generated and initialized at once. As with other modules, this is changed to the form of generating all modules first and then executing the initialization code. (PEP-489)

Significantly improved library module

C implementation of OrderedDict

collections.OrderedDict has been reimplemented in C, 4 to 100 times faster!

Improvement of tmpfile

Bytes type can also be used with arguments that could only be passed with str type (prefix specification, etc.). You will also be able to specify None.

Improvement of ssl module

Added Memory BIO support. With this change, SSL protocol processing can be separated from the actual Socket I / O processing.

Improved traceback module

Added lighter TracebackException, StackSummary and FrameSummary classes

lru_cache improvements

Functools.lru_cache was provided as a decorator to cache the results of function calls, but it has been reimplemented in C.

Security improvements

SSLv3 abolished

It can be made available using ssl.SSLContext, but it is completely removed from the standard library. This change has also been backported to v3.4 and v2.7. This would be a workaround for the SSLv3 vulnerability issue called POODLE Attack. ..

Improved cookie processing

Strict cookie parsing to prevent injection attacks.

Improvements on Windows

Introducing a new installer to replace MSI

There are two types of installers: Web Installer, which downloads necessary files from a small installer at the time of installation, and Offline installer, which includes all standard components. There are 32bit version and 64bit version respectively.

Using MSVC ++ 14.0

Python 3.5 for Windows was built with MSVC ++ 14.0 and the extensions also need to be compiled with it.

Finally

In addition to the ones introduced above, What ’s New In Python 3.5 has various changes. If there is something that looks interesting or usable, I would love to pick it up.

Recommended Posts

What's new in Python 3.5
What's new in Python 3.6
What's new in Python 3.10 (Summary)
What's new in Python 3.4.0 (2) --enum
What's new in Python 3.9 (Summary)
What's new in python3.9 Merge dictionaries
New in Python 3.4.0 (1)-pathlib
Quadtree in Python --2
CURL in python
Metaprogramming in Python
Python 3.3 in Anaconda
Geocoding in python
SendKeys in Python
Meta-analysis in Python
Unittest in python
Discord in Python
DCI in Python
quicksort in python
nCr in python
N-Gram in Python
Programming in python
Plink in Python
Constant in python
pandas 1.2.0 What's new
Lifegame in Python.
FizzBuzz in Python
Sqlite in python
StepAIC in Python
N-gram in python
LINE-Bot [0] in Python
Csv in python
Disassemble in Python
Reflection in Python
Constant in python
nCr in Python.
format in python
Scons in Python3
Puyo Puyo in python
python in virtualenv
PPAP in Python
Quad-tree in Python
Reflection in Python
Chemistry in Python
Hashable in python
DirectLiNGAM in Python
LiNGAM in Python
Flatten in python
flatten in python
What's new in Django 1.8 Conditional Expressions #djangoja
New features in Python 3.4.0 (3)-Single-dispatch generic functions
What's new in datetime that is a bit more useful in Python 3
Sorted list in Python
Daily AtCoder # 36 in Python
Clustering text in Python
Daily AtCoder # 2 in Python
Implement Enigma in python
Daily AtCoder # 32 in Python
Daily AtCoder # 6 in Python
Edit fonts in Python
Singleton pattern in Python
File operations in Python