What’s New In Python 3.7¶
|Date:||March 28, 2017|
This article explains the new features in Python 3.7, compared to 3.6.
For full details, see the changelog.
Prerelease users should be aware that this document is currently in draft form. It will be updated substantially as Python 3.7 moves towards release, so it’s worth checking back even after reading earlier versions.
Summary – Release highlights¶
Other Language Changes¶
- More than 255 arguments can now be passed to a function, and a function can now have more than 255 parameters. (Contributed by Serhiy Storchaka in bpo-12844 and bpo-18896.)
bytearray.fromhex()now ignore all ASCII whitespace, not only spaces. (Contributed by Robert Xiao in bpo-28927.)
ImportErrornow displays module name and module
from ... import ...fails. (Contributed by Matthias Bussonnier in bpo-29546.)
- None yet.
its subclasses can be used as a decorator. (Contributed by Xiang Zhang in
- Added two new opcodes:
CALL_METHODto avoid instantiation of bound method objects for method calls, which results in method calls being faster up to 20%. (Contributed by Yury Selivanov and INADA Naoki in bpo-26110.)
- Fast implementation from standard C library is now used for functions
mathmodule. (Contributed by Serhiy Storchaka in bpo-26121.)
Build and C API Changes¶
- A full copy of libffi is no longer bundled for use when building the
_ctypesmodule on non-OSX UNIX platforms. An installed copy of libffi is now required when building
_ctypeson such platforms. Contributed by Zachary Ware in bpo-27979.
- The fields
wrapperbaseare now of type
const char *rather of
char *. (Contributed by Serhiy Storchaka in bpo-28761.)
- The result of
PyUnicode_AsUTF8()is now of type
const char *rather of
char *. (Contributed by Serhiy Storchaka in bpo-28769.)
- Added functions
PySlice_AdjustIndices(). (Contributed by Serhiy Storchaka in bpo-27867.)
PySlice_GetIndicesEx()is deprecated and replaced with a macro if
Py_LIMITED_APIis not set or set to the value between
0x03060000(not including) or
0x03060100or higher. (Contributed by Serhiy Storchaka in bpo-27867.)
locale, use the
format_string()instead. (Contributed by Garvit in bpo-10379.)
PathEntryFinder.find_spec()) both deprecated in Python 3.4 now emit
DeprecationWarning. (Contributed by Matthias Bussonnier in bpo-29576)
- Using non-integer value for selecting a plural form in
gettextis now deprecated. It never correctly worked. (Contributed by Serhiy Storchaka in bpo-28692.)
API and Feature Removals¶
- Unknown escapes consisting of
'\'and an ASCII letter in replacement templates for
re.sub()were deprecated in Python 3.5, and will now cause an error.
- Removed support of the exclude argument in
tarfile.TarFile.add(). It was deprecated in Python 2.7 and 3.2. Use the filter argument instead.
splitunc()function in the
ntpathmodule was deprecated in Python 3.1, and has now been removed. Use the
tuple()no longer take keyword arguments. The first argument of
int()can now be passes only as positional argument.
Porting to Python 3.7¶
This section lists previously described changes and other bugfixes that may require changes to your code.
Changes in the Python API¶
- A format string argument for
string.Formatter.format()is now positional-only. Passing it as a keyword argument was deprecated in Python 3.5. (Contributed by Serhiy Storchaka in bpo-29193.)
http.cookies.Morselare now read-only. Assigning to them was deprecated in Python 3.5. Use the
set()method for setting them. (Contributed by Serhiy Storchaka in bpo-29192.)
ClassDefAST nodes now have a new
docstringfield. The first statement in their body is not considered as a docstring anymore.
co_lnotabof code object for class and module are affected by this change. (Contributed by INADA Naoki and Eugene Toder in bpo-29463.)
- The mode argument of
os.makedirs()no longer affects the file permission bits of newly-created intermediate-level directories. To set their file permission bits you can set the umask before invoking
makedirs(). (Contributed by Serhiy Storchaka in bpo-19930.)