On 7 June 2016 at 20:28, Ethan Furman email@example.com wrote:
Addition of explicit "single byte" constructors
As binary counterparts to the text ``chr`` function, this PEP proposes the addition of an explicit ``byte`` alternative constructor as a class method on both ``bytes`` and ``bytearray``::
>>> bytes.byte(3) b'\x03' >>> bytearray.byte(3) bytearray(b'\x03')
Bytes.byte() is a great idea. But what’s the point or use case of bytearray.byte(), a mutable array of one pre-defined byte?
Addition of optimised iterator methods that produce ``bytes`` objects
This PEP proposes that ``bytes``, ``bytearray`` and ``memoryview`` gain an optimised ``iterbytes`` method that produces length 1 ``bytes`` objects rather than integers::
for x in data.iterbytes(): # x is a length 1 ``bytes`` object, rather than an integer
Might be good to have an example with concrete output, so you see the one-byte strings coming out of it.
(b'A', b'B', b'C')