Skip to content

Commit db0f99a

Browse files
ethanfurmanhugovkAA-Turner
authored
PEP 467: Include memoryview, drop Python 2->3 conversion text (#3660)
Co-authored-by: Hugo van Kemenade <hugovk@users.noreply.github.com> Co-authored-by: Adam Turner <9087854+AA-Turner@users.noreply.github.com>
1 parent 2cefc28 commit db0f99a

File tree

1 file changed

+9
-14
lines changed

1 file changed

+9
-14
lines changed

peps/pep-0467.rst

Lines changed: 9 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ Discussions-To: https://discuss.python.org/t/42001
55
Status: Draft
66
Type: Standards Track
77
Created: 30-Mar-2014
8-
Python-Version: 3.13
8+
Python-Version: 3.15
99
Post-History: 30-Mar-2014, 15-Aug-2014, 16-Aug-2014, 07-Jun-2016, 01-Sep-2016,
1010
13-Apr-2021, 03-Nov-2021, 27-Dec-2023
1111

@@ -21,6 +21,8 @@ This PEP proposes small adjustments to the APIs of the ``bytes`` and
2121
* Add ``getbyte`` byte retrieval method
2222
* Add ``iterbytes`` alternative iterator
2323

24+
The last two (``getbyte`` and ``iterbytes``) will also be added to ``memoryview``.
25+
2426
Rationale
2527
=========
2628

@@ -41,7 +43,7 @@ painful -- wire format protocols.
4143
This area of programming is characterized by a mixture of binary data and
4244
ASCII compatible segments of text (aka ASCII-encoded text). The addition of
4345
the new constructors, methods, and iterators will aid both in writing new
44-
wire format code, and in porting any remaining Python 2 wire format code.
46+
wire format code, and in updating existing code.
4547

4648
Common use-cases include ``dbf`` and ``pdf`` file formats, ``email``
4749
formats, and ``FTP`` and ``HTTP`` communications, among many others.
@@ -122,8 +124,8 @@ negative numbers. The documentation of the new methods will refer readers to
122124
Addition of "getbyte" method to retrieve a single byte
123125
------------------------------------------------------
124126

125-
This PEP proposes that ``bytes`` and ``bytearray`` gain the method ``getbyte``
126-
which will always return ``bytes``::
127+
This PEP proposes that ``bytes``, ``bytearray``, and ``memoryview`` gain the
128+
method ``getbyte`` which will always return ``bytes``::
127129

128130
>>> b'abc'.getbyte(0)
129131
b'a'
@@ -139,9 +141,9 @@ If an index is asked for that doesn't exist, ``IndexError`` is raised::
139141
Addition of optimised iterator methods that produce ``bytes`` objects
140142
---------------------------------------------------------------------
141143

142-
This PEP proposes that ``bytes`` and ``bytearray`` gain an optimised
143-
``iterbytes`` method that produces length 1 ``bytes`` objects rather than
144-
integers::
144+
This PEP proposes that ``bytes``, ``bytearray``, and ``memoryview`` gain an
145+
optimised ``iterbytes`` method that produces length 1 ``bytes`` objects rather
146+
than integers::
145147

146148
for x in data.iterbytes():
147149
# x is a length 1 ``bytes`` object, rather than an integer
@@ -202,13 +204,6 @@ Developers that use this method frequently will instead have the option to
202204
define their own ``bchr = bytes.fromint`` aliases.
203205

204206

205-
Scope limitation: memoryview
206-
----------------------------
207-
208-
Updating ``memoryview`` with the new item retrieval methods is outside the scope
209-
of this PEP.
210-
211-
212207
References
213208
==========
214209

0 commit comments

Comments
 (0)