[Python-checkins] r58275 - peps/trunk/pep-3137.txt

guido.van.rossum python-checkins at python.org
Thu Sep 27 19:54:02 CEST 2007


Author: guido.van.rossum
Date: Thu Sep 27 19:54:01 2007
New Revision: 58275

Modified:
   peps/trunk/pep-3137.txt
Log:
Decide that bytes/buffer items are ints.

Also:
- Add mutable sequence methods.
- Add fromhex class method.
- "Supports" -> "implements" consistently.


Modified: peps/trunk/pep-3137.txt
==============================================================================
--- peps/trunk/pep-3137.txt	(original)
+++ peps/trunk/pep-3137.txt	Thu Sep 27 19:54:01 2007
@@ -88,9 +88,9 @@
 -------------------
 
 Both bytes and buffer implement the PEP 3118 buffer API.  The bytes
-type only supports read-only requests; the buffer type allows writable
-and data-locked requests as well.  The element data type is always 'B'
-(i.e. unsigned byte).
+type only implements read-only requests; the buffer type allows
+writable and data-locked requests as well.  The element data type is
+always 'B' (i.e. unsigned byte).
 
 Constructors
 ------------
@@ -140,17 +140,12 @@
 Indexing
 --------
 
-**Open Issue:** I'm undecided on whether indexing bytes and buffer
-objects should return small ints (like the bytes type in 3.0a1, and
-like lists or array.array('B')), or bytes/buffer objects of length 1
-(like the str type).  The latter (str-like) approach will ease porting
-code from Python 2.x; but it makes it harder to extract values from a
-bytes array.
+Indexing bytes and buffer returns small ints (like the bytes type in
+3.0a1, and like lists or array.array('B')).
 
 Assignment to an item of a mutable buffer object accepts an int in
-range(256); if we choose the str-like approach for indexing above, it
-also accepts an object implementing the PEP 3118 buffer API, if it has
-length 1.
+range(256).  (To assing from a bytes sequence, use a slice
+assignment.)
 
 Str() and Repr()
 ----------------
@@ -162,7 +157,7 @@
 Operators
 ---------
 
-The following operators are supported by the bytes and buffer types,
+The following operators are implemented by the bytes and buffer types,
 except where mentioned:
 
   - ``b1 + b2``: concatenation.  With mixed bytes/buffer operands,
@@ -186,13 +181,13 @@
 
   - ``hash(b)``: the hash value; only implemented by the bytes type.
 
-Note that the % operator is *not* supported.  It does not appear worth
-the complexity.
+Note that the % operator is *not* implemented.  It does not appear
+worth the complexity.
 
 Methods
 -------
 
-The following methods are supported by bytes as well as buffer, with
+The following methods are implemented by bytes as well as buffer, with
 similar semantics.  They accept anything that implements the PEP 3118
 buffer API for bytes arguments, and return the same type as the object
 whose method is called ("self")::
@@ -216,6 +211,15 @@
 string and returns a bytes sequence, and decoding always takes a bytes
 sequence and returns a Unicode string.
 
+In addition, both types implement the class method ``.fromhex()``,
+which constructs an object from a string containing hexadecimal values
+(with or without spaces between the bytes).
+
+The buffer type implements these additional methods from the
+MutableSequence ABC (see PEP 3119):
+
+  .extend(), .insert(), .append(), .reverse(), .pop(), .remove().
+
 Bytes and the Str Type
 ----------------------
 


More information about the Python-checkins mailing list