Source text — English
Translation — Bahasa Indonesia
One-dimensional memoryviews of hashable (read-only) types with formats B, b or c are now hashable. (Contributed by Antoine Pitrou in :issue:`13411`.)
You don't have to worry anymore about choosing the appropriate exception type between :exc:`OSError`, :exc:`IOError`, :exc:`EnvironmentError`, :exc:`WindowsError`, :exc:`!mmap.error`, :exc:`socket.error` or :exc:`select.error`. All these exception types are now only one: :exc:`OSError`. The other names are kept as aliases for compatibility reasons.
PEP 409 introduces new syntax that allows the display of the chained exception context to be disabled. This allows cleaner error messages in applications that convert between exception types::
Dictionaries used for the storage of objects' attributes are now able to share part of their internal storage between each other (namely, the part which stores the keys and their respective hashes). This reduces the memory consumption of programs creating many instances of non-builtin types.
The implementation of ``sys.implementation`` also introduces a new type to Python: :class:`types.SimpleNamespace`. In contrast to a mapping-based namespace, like :class:`dict`, ``SimpleNamespace`` is attribute-based, like :class:`object`. However, unlike ``object``, ``SimpleNamespace`` instances are writable. This means that you can add, remove, and modify the namespace through normal attribute access.
:meth:`dict.setdefault` now does only one lookup for the given key, making it atomic when used with built-in types.
Builtin functions and types
The sequence documentation has been substantially rewritten to better explain the binary/text sequence distinction and to provide specific documentation sections for the individual builtin sequence types (:issue:`4966`).
$ python -q -X faulthandler
>>> import ctypes
>>> ctypes.string_at(0)
Fatal Python error: Segmentation fault
Current thread 0x00007fb899f39700:
File "/home/python/cpython/Lib/ctypes/__init__.py", line 486 in string_at
File "<stdin>", line 1 in <module>
Segmentation fault
The :deco:`functools.lru_cache` decorator now accepts a ``typed`` keyword argument (that defaults to ``False`` to ensure that it caches values of different types that compare equal in separate cache slots. (Contributed by Raymond Hettinger in :issue:`13227`.)
New constants :const:`~os.RTLD_LAZY`, :const:`~os.RTLD_NOW`, :const:`~os.RTLD_GLOBAL`, :const:`~os.RTLD_LOCAL`, :const:`~os.RTLD_NODELETE`, :const:`~os.RTLD_NOLOAD`, and :const:`~os.RTLD_DEEPBIND` are available on platforms that support them. These are for use with the :func:`sys.setdlopenflags` function, and supersede the similar constants defined in :mod:`ctypes` and :mod:`!DLFCN`. (Contributed by Victor Stinner in :issue:`13226`.)
types
types
Add a new :class:`types.MappingProxyType` class: Read-only proxy of a mapping. (:issue:`14386`)
The new functions :func:`types.new_class` and :func:`types.prepare_class` provide support for :pep:`3115` compliant dynamic type creation. (:issue:`14588`)
:pep:`393` added new Unicode types, macros and functions:
:c:type:`Py_UCS1`, :c:type:`Py_UCS2`, :c:type:`Py_UCS4` types
Deprecated functions and types of the C API
Unicode functions and methods using :c:type:`Py_UNICODE` and :c:expr:`Py_UNICODE*` types: