On 7 June 2016 at 20:28, Ethan Furman <et...@stoneleaf.us> 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. >>> tuple(b"ABC".iterbytes()) (b'A', b'B', b'C') _______________________________________________ Python-Dev mailing list Python-Dev@python.org https://mail.python.org/mailman/listinfo/python-dev Unsubscribe: https://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com