From 3728f0d47a2dfb54deea6ce63e90c139d8dcd9bf Mon Sep 17 00:00:00 2001 From: Ethan Furman Date: Wed, 7 Feb 2024 05:44:54 -0800 Subject: [PATCH] PEP 467: add discouraged use example (#3611) Co-authored-by: Hugo van Kemenade --- peps/pep-0467.rst | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/peps/pep-0467.rst b/peps/pep-0467.rst index 4cdcfe327..033ce087a 100644 --- a/peps/pep-0467.rst +++ b/peps/pep-0467.rst @@ -16,7 +16,7 @@ Post-History: 30-Mar-2014, 15-Aug-2014, 16-Aug-2014, 07-Jun-2016, 01-Sep-2016, Abstract ======== -This PEP proposes five small adjustments to the APIs of the ``bytes`` and +This PEP proposes small adjustments to the APIs of the ``bytes`` and ``bytearray`` types to make it easier to operate entirely in the binary domain: * Add ``fromsize`` alternative constructor @@ -56,10 +56,12 @@ Proposals Addition of explicit "count and byte initialised sequence" constructors ----------------------------------------------------------------------- -To replace the now discouraged behavior, this PEP proposes the addition of an -explicit ``fromsize`` alternative constructor as a class method on both -``bytes`` and ``bytearray`` whose first argument is the count, and whose -second argument is the fill byte to use (defaults to ``\x00``):: +To replace the discouraged behavior of creating zero-filled ``bytes``-like +objects from the basic constructors (i.e. ``bytes(1)`` --> ``b'\x00'``), this +PEP proposes the addition of an explicit ``fromsize`` alternative constructor +as a class method on both ``bytes`` and ``bytearray`` whose first argument +is the count, and whose second argument is the fill byte to use (defaults +to ``\x00``):: >>> bytes.fromsize(3) b'\x00\x00\x00'