diff --git a/peps/pep-0467.rst b/peps/pep-0467.rst index 033ce087a45..95317713b4d 100644 --- a/peps/pep-0467.rst +++ b/peps/pep-0467.rst @@ -24,6 +24,8 @@ This PEP proposes small adjustments to the APIs of the ``bytes`` and * Add ``getbyte`` byte retrieval method * Add ``iterbytes`` alternative iterator +The last two (``getbyte`` and ``iterbytes``) will also be added to ``memoryview``. + Rationale ========= @@ -44,7 +46,7 @@ painful -- wire format protocols. This area of programming is characterized by a mixture of binary data and ASCII compatible segments of text (aka ASCII-encoded text). The addition of the new constructors, methods, and iterators will aid both in writing new -wire format code, and in porting any remaining Python 2 wire format code. +wire format code, and in updating existing code. Common use-cases include ``dbf`` and ``pdf`` file formats, ``email`` formats, and ``FTP`` and ``HTTP`` communications, among many others. @@ -125,8 +127,8 @@ negative numbers. The documentation of the new methods will refer readers to Addition of "getbyte" method to retrieve a single byte ------------------------------------------------------ -This PEP proposes that ``bytes`` and ``bytearray`` gain the method ``getbyte`` -which will always return ``bytes``:: +This PEP proposes that ``bytes``, ``bytearray``, and ``memoryview`` gain the +method ``getbyte`` which will always return ``bytes``:: >>> b'abc'.getbyte(0) b'a' @@ -142,9 +144,9 @@ If an index is asked for that doesn't exist, ``IndexError`` is raised:: Addition of optimised iterator methods that produce ``bytes`` objects --------------------------------------------------------------------- -This PEP proposes that ``bytes`` and ``bytearray`` gain an optimised -``iterbytes`` method that produces length 1 ``bytes`` objects rather than -integers:: +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 @@ -205,13 +207,6 @@ Developers that use this method frequently will instead have the option to define their own ``bchr = bytes.fromint`` aliases. -Scope limitation: memoryview ----------------------------- - -Updating ``memoryview`` with the new item retrieval methods is outside the scope -of this PEP. - - References ==========