[Python-checkins] cpython: What's New in Python 3.5: add pep 461 (bytes%args) and 465 (a at b)
victor.stinner
python-checkins at python.org
Mon Mar 30 15:06:12 CEST 2015
https://hg.python.org/cpython/rev/00c982c9f681
changeset: 95297:00c982c9f681
user: Victor Stinner <victor.stinner at gmail.com>
date: Mon Mar 30 15:04:45 2015 +0200
summary:
What's New in Python 3.5: add pep 461 (bytes%args) and 465 (a at b)
files:
Doc/whatsnew/3.5.rst | 45 +++++++++++++++++++++++++++++--
1 files changed, 42 insertions(+), 3 deletions(-)
diff --git a/Doc/whatsnew/3.5.rst b/Doc/whatsnew/3.5.rst
--- a/Doc/whatsnew/3.5.rst
+++ b/Doc/whatsnew/3.5.rst
@@ -64,12 +64,12 @@
Summary -- Release highlights
=============================
-.. This section singles out the most important changes in Python 3.3.
+.. This section singles out the most important changes in Python 3.5.
Brevity is key.
New syntax features:
-* None yet.
+* :pep:`465`, a new matrix multiplication operator: ``a @ b``.
New library modules:
@@ -78,7 +78,8 @@
New built-in features:
-* None yet.
+* ``bytes % args``, ``bytearray % args``: :pep:`461` - Adding ``%`` formatting
+ to bytes and bytearray
Implementation improvements:
@@ -114,6 +115,44 @@
PEP written by Carl Meyer
+PEP 461 - Adding % formatting to bytes and bytearray
+----------------------------------------------------
+
+This PEP proposes adding % formatting operations similar to Python 2's ``str``
+type to :class:`bytes` and :class:`bytearray`.
+
+Examples::
+
+ >>> b'Hello %s!' % b'World'
+ b'Hello World!'
+ >>> b'x=%i y=%f' % (1, 2.5)
+ b'x=1 y=2.500000'
+
+Unicode is not allowed for ``%s``, but it is accepted by ``%a`` (equivalent of
+``repr(obj).encode('ascii', 'backslashreplace')``)::
+
+ >>> b'Hello %s!' % 'World'
+ Traceback (most recent call last):
+ File "<stdin>", line 1, in <module>
+ TypeError: %b requires bytes, or an object that implements __bytes__, not 'str'
+ >>> b'price: %a' % '10€'
+ b"price: '10\\u20ac'"
+
+.. seealso::
+
+ :pep:`461` -- Adding % formatting to bytes and bytearray
+
+
+PEP 465 - A dedicated infix operator for matrix multiplication
+--------------------------------------------------------------
+
+This PEP proposes a new binary operator to be used for matrix multiplication,
+called ``@``. (Mnemonic: ``@`` is ``*`` for mATrices.)
+
+.. seealso::
+
+ :pep:`465` -- A dedicated infix operator for matrix multiplication
+
PEP 471 - os.scandir() function -- a better and faster directory iterator
-------------------------------------------------------------------------
--
Repository URL: https://hg.python.org/cpython
More information about the Python-checkins
mailing list