[Python-Dev] PEP 467: last round (?) (original) (raw)
Ethan Furman ethan at stoneleaf.us
Thu Sep 1 18:04:33 EDT 2016
- Previous message (by thread): [Python-Dev] PEP 467: last round (?)
- Next message (by thread): [Python-Dev] PEP 467: last round (?)
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
On 09/01/2016 02:06 PM, Victor Stinner wrote:
2016-09-01 21:36 GMT+02:00 Ethan Furman:
Abstract ========
This PEP proposes five small adjustments to the APIs of the
bytes
andbytearray
types to make it easier to operate entirely in the binary domain: You should add bchr() in the Abstract.
Done.
* Deprecate passing single integer values to
bytes
andbytearray
* Addbytes.fromsize
andbytearray.fromsize
alternative constructors I understand that main reason for this change is to catch bugs when bytes(obj) is used and obj is not supposed to be an integer. So I expect that bytes(int) will be quickly deprecated, but the PEP doesn't schedule a removal of the feature. So it looks more than only adding an alias to bytes(int). I would prefer to either schedule a removal of bytes(int), or remove bytes.fromsize() from the PEP.
The PEP states that bytes(x)
will not be removed while 2.7 is supported. Once 2.7 is no longer a concern we can visit the question of removing that behavior.
* Add
bytes.fromord
andbytearray.fromord
alternative constructors Hum, you already propose to add a builtin function. Why would we need two ways to create a single byte?
bchr
to mirrorchr
fromord
to replace the mistaken purpose of the default constructor
* Add
bytes.getbyte
andbytearray.getbyte
byte retrieval methods * Addbytes.iterbytes
andbytearray.iterbytes
alternative iterators I like these ones :-)
Cool.
In particular, there's a reasonable case to be made that
bytes(x)
(wherex
is an integer) should behave like thebytes.fromint(x)
proposal in this PEP. "fromint"? Is it bytes.fromord()/bchr()?
Oops, fixed.
-- ~Ethan
- Previous message (by thread): [Python-Dev] PEP 467: last round (?)
- Next message (by thread): [Python-Dev] PEP 467: last round (?)
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]