@@ -5,7 +5,7 @@ Discussions-To: https://discuss.python.org/t/42001
5
5
Status: Draft
6
6
Type: Standards Track
7
7
Created: 30-Mar-2014
8
- Python-Version: 3.13
8
+ Python-Version: 3.15
9
9
Post-History: 30-Mar-2014, 15-Aug-2014, 16-Aug-2014, 07-Jun-2016, 01-Sep-2016,
10
10
13-Apr-2021, 03-Nov-2021, 27-Dec-2023
11
11
@@ -21,6 +21,8 @@ This PEP proposes small adjustments to the APIs of the ``bytes`` and
21
21
* Add ``getbyte `` byte retrieval method
22
22
* Add ``iterbytes `` alternative iterator
23
23
24
+ The last two (``getbyte `` and ``iterbytes ``) will also be added to ``memoryview ``.
25
+
24
26
Rationale
25
27
=========
26
28
@@ -41,7 +43,7 @@ painful -- wire format protocols.
41
43
This area of programming is characterized by a mixture of binary data and
42
44
ASCII compatible segments of text (aka ASCII-encoded text). The addition of
43
45
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.
45
47
46
48
Common use-cases include ``dbf `` and ``pdf `` file formats, ``email ``
47
49
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
122
124
Addition of "getbyte" method to retrieve a single byte
123
125
------------------------------------------------------
124
126
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 ``::
127
129
128
130
>>> b'abc'.getbyte(0)
129
131
b'a'
@@ -139,9 +141,9 @@ If an index is asked for that doesn't exist, ``IndexError`` is raised::
139
141
Addition of optimised iterator methods that produce ``bytes `` objects
140
142
---------------------------------------------------------------------
141
143
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::
145
147
146
148
for x in data.iterbytes():
147
149
# 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
202
204
define their own ``bchr = bytes.fromint `` aliases.
203
205
204
206
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
-
212
207
References
213
208
==========
214
209
0 commit comments